Trait flatdata::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

Object Safety§

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§