hopr_primitive_types::traits

Trait BytesRepresentable

Source
pub trait BytesRepresentable<E = GeneralError>: AsRef<[u8]> + for<'a> TryFrom<&'a [u8], Error = E> {
    const SIZE: usize;

    // Provided method
    fn into_boxed(self) -> Box<[u8]> { ... }
}
Expand description

Represents a type that is already internally represented by a fixed size byte array, and therefore requires no memory allocation to represent the type in binary encoding.

This is a strict subset of BytesEncodable, see its documentation for details.

Required Associated Constants§

Source

const SIZE: usize

Size of the encoded byte array.

Provided Methods§

Source

fn into_boxed(self) -> Box<[u8]>

Convenience function to copy this type’s binary representation into a Box.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§