Trait packtool::Packed[][src]

pub trait Packed: Sized {
    const SIZE: usize;

    fn unchecked_read_from_slice(slice: &[u8]) -> Self;
fn unchecked_write_to_slice(&self, _slice: &mut [u8]);
fn check(slice: &[u8]) -> Result<(), Error>; fn read(view: View<'_, Self>) -> Self { ... } }
Expand description

trait to define how a fixed size Packed object is serialized into a byte slice representation.

see crate documentation for more information.

Associated Constants

the static size of a packed object in a byte array

this is not necessarily the ::std::mem::size_of::<Self>() but the size it takes to have this object on a slice of memory.

Required methods

assuming the given slice if valid, perform a conversion from the slice to the object.

assuming there is enough slice available in the

check the validity of the given slice to hold the appropriate value

the length of the slice is already handled by the View::try_from_slice method so no need to do that again in here.

Provided methods

assuming the given slice if valid, perform a conversion from the slice to the object.

it should be assumed the checks have been performed appropriately since we are passing in the View and not the raw slice.

Implementations on Foreign Types

Implementors