Trait meshx::attrib::Bytes

source ·
pub trait Bytes
where Self: Sized,
{ // Provided methods fn as_bytes(&self) -> &[u8] { ... } fn interpret_bytes(bytes: &[u8]) -> &Self { ... } }
Expand description

Helper trait to interpret a slice of bytes representing a sized type.

Note: this trait is meant to be used transiently on the same platform, and so doesn’t care about endianness. In other words, the slice of bytes generated by this trait should not be stored anywhere that outlives the lifetime of the program.

Provided Methods§

source

fn as_bytes(&self) -> &[u8]

Get a slice of bytes representing Self.

source

fn interpret_bytes(bytes: &[u8]) -> &Self

Panics if the size of the given bytes slice is not equal to the size of Self.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: Sized> Bytes for T