Skip to main content

ExternalMutStorage

Struct ExternalMutStorage 

Source
pub struct ExternalMutStorage { /* private fields */ }
Expand description

Type-erased mutable external owned backing storage (Box<[T]>, custom-allocator wrappers, mutable pool leases, FFI writable buffers).

Both read and in-place write access are strictly zero-copy; calling into_inner recovers the original owner S zero-copy.

Implementations§

Source§

impl ExternalMutStorage

Source

pub fn new<S>(owner: S) -> ExternalMutStorage
where S: ByteStorageMut + Send + Sync + 'static,

Wrap any S: ByteStorageMut + Send + Sync + 'static zero-copy.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Active immutable byte view.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ

Active mutable byte view (zero-copy in place).

Source

pub const fn len(&self) -> usize

Active byte length.

Source

pub const fn is_empty(&self) -> bool

Whether the active byte view is empty.

Source

pub fn truncate(&mut self, byte_len: usize)

Narrow active byte length without touching or copying the external owner.

Source

pub fn downcast_ref<S>(&self) -> Option<&S>
where S: 'static,

Borrow the original external owner if its concrete type is S.

Source

pub fn downcast_mut<S>(&mut self) -> Option<&mut S>
where S: 'static,

Mutably borrow the original external owner if its concrete type is S.

Source

pub fn into_inner<S>(self) -> Result<S, ExternalMutStorage>
where S: 'static,

Recover the original external owner S zero-copy; returns Err(self) untouched if the stored type is not S.

Trait Implementations§

Source§

impl ByteStorage for ExternalMutStorage

Source§

fn as_bytes(&self) -> &[u8] ⓘ

Underlying bytes in native endianness.
Source§

impl ByteStorageMut for ExternalMutStorage

Source§

fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ

Mutable underlying bytes in native endianness.
Source§

impl Debug for ExternalMutStorage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.