/// Allocate a buffer and initialize it from a slice.
Allocate a buffer and initialize it from a slice.
Allocate a buffer and initialize it from a slice .
pub fn from_slice(data: &[u8], align: usize) -> Option<AlignedBuf> {
        unsafe {
            match AlignedBuf::alloc_uninit(data.len(), align) {
                None => None,
                Some(mut b) => {
                    ptr::copy_nonoverlapping(data.as_ptr(), b.buf, data.len());
                    if data.len() != b.len {
                        assert!(b.len > data.len());
                        ptr::write_bytes((b.buf as usize + data.len()) as *mut u8, 0, b.len - data.len())
                    };
                    b.valid = b.len;
                    Some(b)
                }
            }
        }
    }
pub fn from_slice ( data : & [ u8 ] , align : usize ) -> Option < AlignedBuf > { unsafe { match AlignedBuf :: alloc_uninit ( data . len ( ) , align ) { None => None , Some ( mut b ) => { ptr :: copy_nonoverlapping ( data . as_ptr ( ) , b . buf , data . len ( ) ) ; if data . len ( ) != b . len { assert ! ( b len data len ( ) ) ; ptr :: write_bytes ( ( b . buf as usize + data . len ( ) ) as * mut u8 , 0 , b . len - data . len ( ) ) } ; b . valid = b . len ; Some ( b ) } } } }
Allocate a buffer and initialize it from a slice.
Allocate a buffer and initialize it from a slice .
data
&[u8]
align
usize