Skip to main content

Memory

Struct Memory 

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

A shared storage domain retained by owned results.

Cloning this handle shares existing state and allocates no new block.

Implementations§

Source§

impl Memory

Source

pub fn new(account: Arc<MemoryAccount>) -> Self

Uses caller-supplied shared state; this constructor allocates nothing.

Source

pub fn limit(&self) -> usize

The immutable allowance in bytes.

Source

pub fn used(&self) -> usize

Currently reserved bytes, including pending allocations and growth peaks.

Source

pub fn same_account(&self, other: &Self) -> bool

Whether two handles share exactly the same account, without allocation.

Source

pub fn work_used(&self) -> usize

Cumulative work already admitted, including operations that later failed.

Source

pub fn work_remaining(&self) -> usize

Currently available aggregate work units, without reserving them. Concurrent consumption can reduce this observation; every operation must still use Self::charge_work before execution.

Source

pub fn charge_work(&self, amount: u64) -> Result<(), MemoryError>

Charges work before performing it; storage release never refunds work.

An amount unrepresentable on this target is refused before any work, preserving the existing u64 scanning API on 32-bit targets.

Source

pub fn reserve(&self, bytes: usize) -> Result<MemoryReservation, MemoryError>

Reserves storage for an adapter-owned allocation before allocating it.

Keep the returned guard until after deallocation, including rollback on failure. Reserve the complete actual capacity; a growth must retain the old guard while admitting the replacement. This bridge does not allocate.

Source

pub fn vector<T>(&self) -> OwnedVec<T>

An empty owned collection sharing this domain, without allocating storage.

Source

pub fn map<K: HashWork, V>(&self) -> OwnedMap<K, V>

An empty accounted hash map, without allocating storage.

Source

pub fn string(&self) -> OwnedString

Empty accounted UTF-8 text, without allocating storage.

Trait Implementations§

Source§

impl Clone for Memory

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Memory

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Work for Memory

Source§

type Retained = ()

Storage ownership retained by the allocator independently of borrowed work.
Source§

fn retain_storage(&self)

Keeps an allocation’s account alive even if its collection is forgotten. Owned Memory already holds that account; borrowed Execution supplies one owning handle per collection without allocating a new account.
Source§

fn into_storage_owner(self, (): ()) -> Memory

Moves the existing account owner when finishing independently owned storage. The sealed implementations preserve the account without cloning it.
Source§

fn with_storage_owner(&self, memory: Memory) -> (Self, ())

Attaches current work while moving an existing same-account owner. The caller verifies account identity before transferring storage.
Source§

fn memory(&self) -> &Memory

The account retaining allocated capacity.
Source§

fn charge_work(&self, amount: u64) -> Result<(), MemoryError>

Admits work before execution, against every applicable ceiling.
Source§

fn read_scoped_source<'source: 'operation, 'operation>( &'operation self, parser: &'source Parser, data: &'source [u8], base: u64, encoding: Encoding, depth: u32, ) -> Result<ScopedReader<'source, 'operation>>

Opens original input while borrowing this operation only for decoding. Parsed elements and scalar views retain the longer original input lifetime; no result needs to keep a completed operation alive merely because it borrows input. Source and current ceilings still apply to every read, scratch allocation and copy before that work. A cursor itself cannot escape a local operation: Read more
Source§

fn read_nested<'source>( &self, parser: &'source Parser, data: &'source [u8], base: u64, encoding: Encoding, outer: u32, ) -> Result<Reader<'source>>
where Self: 'source,

Opens original nested bytes without discarding this execution boundary. Memory retains its existing source-plus-aggregate admission; Execution additionally preserves the current root operation before any decode. Source parser/data/base/encoding and actual outer + 1 depth remain original. A transition replaces a previous foreign source ceiling, never the operation owner. A fresh document uses depth zero through Work::read_source, rather than inventing a nested carrier level. Read more
Source§

fn read_source<'source>( &self, parser: &'source Parser, data: &'source [u8], base: u64, encoding: Encoding, depth: u32, ) -> Result<Reader<'source>>
where Self: 'source,

Opens an original source window at its actual ASN.1 depth. Read more
Source§

fn read_scoped_nested<'source: 'operation, 'operation>( &'operation self, parser: &'source Parser, data: &'source [u8], base: u64, encoding: Encoding, outer: u32, ) -> Result<ScopedReader<'source, 'operation>>

Nested form of Work::read_scoped_source, retaining actual outer+1 depth. Only decoding borrows this operation; returned input views do not.
Source§

fn vector<T>(&self) -> OwnedVec<T, Self>

Creates empty accounted scratch retaining this execution boundary. Read more
Source§

fn map<K: HashWork, V>(&self) -> OwnedMap<K, V, Self>

Creates a bounded scratch map in this storage and execution domain. Hash/probes, table growth and value movement retain the same ceilings.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.