pub fn write_one<T: Copy>(&mut self, data: &T, offset: Option<usize>)
                              -> Result<(), Error>
    {
        let ptr = match self.ptr {
            None => return Err(Error::MemoryNotHostWritable),
            Some(rpu) => rpu
        };

        let stride = _stride(::std::mem::size_of::<T>(),
                             self.element_alignment as usize);
        let offset = offset.unwrap_or(0_usize);
        assert!(stride * (offset + 1) <= self.size as usize);

        unsafe {
            let p = ptr.offset((offset * stride) as isize) as *mut T;
            *p = *data;
        }

        // mark dirty
        self.dirty.store(true, Ordering::Relaxed);

        Ok(())
    }
// offset is measured in "count of T's plus alignment padding", not in bytes.
offset is measured in "count of T's plus alignment padding", not in bytes.
offset is measured in " count of T ' s plus alignment padding " not in bytes .
pub fn write_one<T: Copy>(&mut self, data: &T, offset: Option<usize>)
                              -> Result<(), Error>
    {
        let ptr = match self.ptr {
            None => return Err(Error::MemoryNotHostWritable),
            Some(rpu) => rpu
        };
        let stride = _stride(::std::mem::size_of::<T>(),
                             self.element_alignment as usize);
        let offset = offset.unwrap_or(0_usize);
        assert!(stride * (offset + 1) <= self.size as usize);
        unsafe {
            let p = ptr.offset((offset * stride) as isize) as *mut T;
            *p = *data;
        }
        // mark dirty
        self.dirty.store(true, Ordering::Relaxed);
        Ok(())
    }
pub fn write_one < T : Copy > ( & mut self , data : & T , offset : Option < usize > ) -> Result < ( ) , Error > { let ptr = match self . ptr { None => return Err ( Error :: MemoryNotHostWritable ) , Some ( rpu ) => rpu } ; let stride = _stride ( :: std :: mem :: size_of :: < T > ( ) , self . element_alignment as usize ) ; let offset = offset . unwrap_or ( 0_usize ) ; assert ! ( stride ( offset 1 ) self size as usize ) ; unsafe { let p = ptr . offset ( ( offset * stride ) as isize ) as * mut T ; * p = * data ; } // mark dirty self . dirty . store ( true , Ordering :: Relaxed ) ; Ok ( ( ) ) }
offset is measured in "count of T's plus alignment padding", not in bytes.
offset is measured in " count of T ' s plus alignment padding " not in bytes .
&mut self
data
&T
offset
Option<usize>
&mut self
data
&T
offset
Option<usize>