Skip to main content

ExternalStorage

Struct ExternalStorage 

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

Full re-export of zenpixels core types (zero module name collisions!). Type-erased immutable external owned backing storage (Arc<[T]>, &'static [T], memory-mapped files, shared buffer pools, FFI read-only buffers).

Read access is strictly zero-copy. Requesting mutable access through PixelStorage or PixelBuf performs copy-on-write promotion into 64-byte aligned owned storage; calling into_inner recovers the original owner S zero-copy without touching its backing allocation.

Implementations§

Source§

impl ExternalStorage

Source

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

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

Source

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

Active immutable byte view (bounded by any prior truncate).

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 into_inner<S>(self) -> Result<S, ExternalStorage>
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 ExternalStorage

Source§

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

Underlying bytes in native endianness.
Source§

impl Debug for ExternalStorage

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.