SliceExt

Trait SliceExt 

Source
pub trait SliceExt<'a>
where Self: Sized,
{ // Required methods fn from_bytes(data: &'a [u8]) -> Result<Self, ResourceStorageError>; fn as_bytes(&self) -> &'a [u8] ; }
Expand description

Enhanced slices of flatdata Structs so that they can be created from bytes / converted to bytes Note: TryFrom/AsRef cannot be used, since slice is a foreign type

Required Methods§

Source

fn from_bytes(data: &'a [u8]) -> Result<Self, ResourceStorageError>

Create a slice from an array of bytes

Source

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

Get byte representation of the slice

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.

Implementations on Foreign Types§

Source§

impl<'a, T> SliceExt<'a> for &'a [T]
where T: Struct,

Source§

fn from_bytes(data: &[u8]) -> Result<Self, ResourceStorageError>

Source§

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

Implementors§