Storage

Trait Storage 

Source
pub trait Storage<T: Copy + Default>:
    AsRef<[T]>
    + AsMut<[T]>
    + Unpin {
    // Required methods
    fn with_size(size: usize) -> Self
       where Self: Sized;
    fn max_len() -> usize;

    // Provided methods
    fn from_slice(buf: &[T]) -> Self
       where Self: Sized { ... }
    fn space_left(&self) -> usize { ... }
    fn len(&self) -> usize { ... }
}
Expand description

Objects that store and own Ts (Box<[T]>, Vec<T>, StaticBuf<[T; 32]>, etc). This allows for generic byte storage types for byte buffers. This also enable generic storage for any T type but the Copy + Default requirement might be too restricting for all cases.

Required Methods§

Source

fn with_size(size: usize) -> Self
where Self: Sized,

Source

fn max_len() -> usize

Provided Methods§

Source

fn from_slice(buf: &[T]) -> Self
where Self: Sized,

Source

fn space_left(&self) -> usize

Source

fn len(&self) -> usize

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<T: Copy + Unpin + Default> Storage<T> for Box<[T]>

Source§

fn with_size(size: usize) -> Self
where Self: Sized,

Source§

fn from_slice(buf: &[T]) -> Self
where Self: Sized,

Source§

fn max_len() -> usize

Source§

impl<T: Copy + Unpin + Default> Storage<T> for Vec<T>

Source§

fn with_size(size: usize) -> Self
where Self: Sized,

Source§

fn from_slice(buf: &[T]) -> Self
where Self: Sized,

Source§

fn len(&self) -> usize

Source§

fn max_len() -> usize

Implementors§

Source§

impl<T: Copy + Unpin + Default, ArrayBuf: AsRef<[T]> + AsMut<[T]> + Default + Copy + Unpin> Storage<T> for StaticBuf<T, ArrayBuf>