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
impl Memory
Sourcepub fn new(account: Arc<MemoryAccount>) -> Self
pub fn new(account: Arc<MemoryAccount>) -> Self
Uses caller-supplied shared state; this constructor allocates nothing.
Sourcepub fn used(&self) -> usize
pub fn used(&self) -> usize
Currently reserved bytes, including pending allocations and growth peaks.
Sourcepub fn same_account(&self, other: &Self) -> bool
pub fn same_account(&self, other: &Self) -> bool
Whether two handles share exactly the same account, without allocation.
Sourcepub fn work_used(&self) -> usize
pub fn work_used(&self) -> usize
Cumulative work already admitted, including operations that later failed.
Sourcepub fn work_remaining(&self) -> usize
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.
Sourcepub fn charge_work(&self, amount: u64) -> Result<(), MemoryError>
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.
Sourcepub fn reserve(&self, bytes: usize) -> Result<MemoryReservation, MemoryError>
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.
Sourcepub fn vector<T>(&self) -> OwnedVec<T>
pub fn vector<T>(&self) -> OwnedVec<T>
An empty owned collection sharing this domain, without allocating storage.
Sourcepub fn map<K: HashWork, V>(&self) -> OwnedMap<K, V>
pub fn map<K: HashWork, V>(&self) -> OwnedMap<K, V>
An empty accounted hash map, without allocating storage.
Sourcepub fn string(&self) -> OwnedString
pub fn string(&self) -> OwnedString
Empty accounted UTF-8 text, without allocating storage.
Trait Implementations§
Source§impl Work for Memory
impl Work for Memory
Source§type Retained = ()
type Retained = ()
Source§fn retain_storage(&self)
fn retain_storage(&self)
Source§fn into_storage_owner(self, (): ()) -> Memory
fn into_storage_owner(self, (): ()) -> Memory
Source§fn with_storage_owner(&self, memory: Memory) -> (Self, ())
fn with_storage_owner(&self, memory: Memory) -> (Self, ())
Source§fn charge_work(&self, amount: u64) -> Result<(), MemoryError>
fn charge_work(&self, amount: u64) -> Result<(), MemoryError>
Source§fn work_remaining(&self) -> usize
fn work_remaining(&self) -> usize
Work::charge_work would admit now, across every
ceiling it checks, without reserving it. Read moreSource§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>>
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>>
Source§fn read_nested<'source>(
&self,
parser: &'source Parser,
data: &'source [u8],
base: u64,
encoding: Encoding,
outer: u32,
) -> Result<Reader<'source>>where
Self: 'source,
fn read_nested<'source>(
&self,
parser: &'source Parser,
data: &'source [u8],
base: u64,
encoding: Encoding,
outer: u32,
) -> Result<Reader<'source>>where
Self: 'source,
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 moreSource§fn read_source<'source>(
&self,
parser: &'source Parser,
data: &'source [u8],
base: u64,
encoding: Encoding,
depth: u32,
) -> Result<Reader<'source>>where
Self: 'source,
fn read_source<'source>(
&self,
parser: &'source Parser,
data: &'source [u8],
base: u64,
encoding: Encoding,
depth: u32,
) -> Result<Reader<'source>>where
Self: 'source,
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>>
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>>
Work::read_scoped_source, retaining actual outer+1
depth. Only decoding borrows this operation; returned input views do not.