Skip to main content

SharedAllocationController

Struct SharedAllocationController 

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

Allocation controller that shares a view into another Bytes behind an Arc.

The shared content is lazily copied into a private buffer on first mutable access (copy-on-write), behind a Once so the private buffer is materialized exactly once.

Trait Implementations§

Source§

impl AllocationController for SharedAllocationController

Source§

fn alloc_align(&self) -> usize

The alignment this allocation was created with.
Source§

fn property(&self) -> AllocationProperty

Returns memory property for the current allocation.
Source§

fn capacity(&self) -> usize

The total byte capacity of the allocation, WITHOUT materializing lazy storage. Read more
Source§

fn memory( &self, policy: AccessPolicy, ) -> Result<&[MaybeUninit<u8>], AccessError>

Returns a view of the memory of the whole allocation, subject to policy. Read more
Source§

unsafe fn memory_mut( &mut self, policy: AccessPolicy, ) -> Result<&mut [MaybeUninit<u8>], AccessError>

Returns a mutable view of the memory of the whole allocation, subject to policy. Read more
Source§

fn split( &mut self, offset: usize, ) -> Result<(Box<dyn AllocationController>, Box<dyn AllocationController>), SplitError>

Splits the current allocation in multiple separate allocations.
Source§

fn view( &self, start: usize, end: usize, ) -> Option<Box<dyn AllocationController>>

Returns a zero-copy controller over the sub-range [start, end) of this allocation when the backend supports cheap sub-views (files and shared buffers), borrowing &self. Returns None otherwise.
Source§

fn duplicate(&self) -> Option<Box<dyn AllocationController>>

Duplicates the current allocation with a clone on write strategy if the allocation controller supports it.
Source§

unsafe fn copy_into(&self, buf: &mut [u8])

Reads the data from the current allocation controller and copy its content into the provided buffer. Read more
Source§

fn grow(&mut self, size: usize, align: usize) -> Result<(), AllocationError>

Extends the provided Allocation to a new size with specified alignment. Read more
Source§

fn try_detach(&mut self) -> Option<NonNull<u8>>

Indicates whether the allocation uses the Rust alloc crate and can be safely managed by another data structure. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoComptime for T

Source§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.