pub trait Work: Clone + Sealed {
type Retained: Debug;
// Required methods
fn retain_storage(&self) -> Self::Retained;
fn into_storage_owner(self, retained: Self::Retained) -> Memory;
fn with_storage_owner(&self, memory: Memory) -> (Self, Self::Retained);
fn memory(&self) -> &Memory;
fn charge_work(&self, amount: u64) -> Result<(), MemoryError>;
// Provided methods
fn vector<T>(&self) -> OwnedVec<T, Self> { ... }
fn map<K: HashWork, V>(&self) -> OwnedMap<K, V, Self> { ... }
}Expand description
Required Associated Types§
Required Methods§
Sourcefn retain_storage(&self) -> Self::Retained
fn retain_storage(&self) -> Self::Retained
Sourcefn into_storage_owner(self, retained: Self::Retained) -> Memory
fn into_storage_owner(self, retained: Self::Retained) -> Memory
Moves the existing account owner when finishing independently owned storage. The sealed implementations preserve the account without cloning it.
Sourcefn with_storage_owner(&self, memory: Memory) -> (Self, Self::Retained)
fn with_storage_owner(&self, memory: Memory) -> (Self, Self::Retained)
Attaches current work while moving an existing same-account owner. The caller verifies account identity before transferring storage.
Sourcefn charge_work(&self, amount: u64) -> Result<(), MemoryError>
fn charge_work(&self, amount: u64) -> Result<(), MemoryError>
Admits work before execution, against every applicable ceiling.
Provided Methods§
Sourcefn vector<T>(&self) -> OwnedVec<T, Self>
fn vector<T>(&self) -> OwnedVec<T, Self>
Creates empty accounted scratch retaining this execution boundary.
No allocation occurs until a fallible growth operation. A collection
borrowing Execution cannot outlive that parser or execution account.
§Examples
use std::sync::Arc;
use structured_asn1::{Parser, memory::{Memory, MemoryAccount, Work}};
let parser = Parser::ber(Memory::new(Arc::new(MemoryAccount::new(1024, 1024))));
let reader = parser.read(&[], 0).unwrap();
let mut scratch = reader.execution().vector();
scratch.try_push(42_u8)?;
assert_eq!(&*scratch, &[42]);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".