bytes_utils::string

Trait Storage

Source
pub unsafe trait Storage:
    AsRef<[u8]>
    + Default
    + Sized {
    type Creator: Default + StorageMut;

    // Required methods
    fn from_creator(creator: Self::Creator) -> Self;
    fn split_at(self, at: usize) -> (Self, Self);
}
Expand description

The backing storage for StrInner

This is currently a technical detail of the crate, users are not expected to implement this trait. Use Str or StrMut type aliases.

§Safety

The storage must act “sane”. But what exactly it means is not yet analyzed and may change in future versions. Don’t implement the trait (at least not yet).

Required Associated Types§

Source

type Creator: Default + StorageMut

A type that can be used to build the storage incrementally.

For mutable storages, it may be itself. For immutable one, there needs to be a mutable counterpart that can be converted to immutable later on.

Required Methods§

Source

fn from_creator(creator: Self::Creator) -> Self

Converts the creator (mutable storage) to self.

In case of mutable storages, this should be identity.

Source

fn split_at(self, at: usize) -> (Self, Self)

Splits the storage at the given byte index and creates two non-overlapping instances.

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 Storage for Bytes

Source§

type Creator = BytesMut

Source§

fn from_creator(creator: Self::Creator) -> Self

Source§

fn split_at(self, at: usize) -> (Self, Self)

Source§

impl Storage for BytesMut

Source§

type Creator = BytesMut

Source§

fn from_creator(creator: Self::Creator) -> Self

Source§

fn split_at(self, at: usize) -> (Self, Self)

Implementors§