#[repr(C)]pub struct Word { /* private fields */ }
Expand description
Eight bytes of memory with opaque interior. Use capnp_word!()
to construct one of these.
This type is used to ensure that the data of a message is properly aligned.
Implementations
sourceimpl Word
impl Word
sourcepub fn allocate_zeroed_vec(length: usize) -> Vec<Word>
pub fn allocate_zeroed_vec(length: usize) -> Vec<Word>
Does this, but faster:
::std::iter::repeat(Word(0)).take(length).collect()
sourcepub unsafe fn bytes_to_words<'a>(bytes: &'a [u8]) -> &'a [Word]
pub unsafe fn bytes_to_words<'a>(bytes: &'a [u8]) -> &'a [Word]
Converts a byte slice into a Word
slice. Unsafe due to possible alignment issues.
Only call this if you know that either
bytes.to_ptr()
falls on an eight-byte boundary, or- your processor is okay with unaligned reads.
sourcepub unsafe fn bytes_to_words_mut<'a>(bytes: &'a mut [u8]) -> &'a mut [Word]
pub unsafe fn bytes_to_words_mut<'a>(bytes: &'a mut [u8]) -> &'a mut [Word]
Converts a mutable byte slice into a mutable Word
slice. Unsafe due to possible
alignment issues. Only call this if you know that either
bytes.to_ptr()
falls on an eight-byte boundary, or- your processor is okay with unaligned reads and writes
pub fn words_to_bytes<'a>(words: &'a [Word]) -> &'a [u8] ⓘ
pub fn words_to_bytes_mut<'a>(words: &'a mut [Word]) -> &'a mut [u8] ⓘ
Trait Implementations
impl Copy for Word
impl Eq for Word
impl StructuralEq for Word
impl StructuralPartialEq for Word
Auto Trait Implementations
impl RefUnwindSafe for Word
impl Send for Word
impl Sync for Word
impl Unpin for Word
impl UnwindSafe for Word
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more