pub struct Execution<'a> { /* private fields */ }Expand description
A borrowed aggregate account and original parser-session work ceiling.
Obtain this from crate::Reader::execution. Copies allocate nothing and
acquire no shared ownership. Scratch storage and work use the reader’s
current account; rebinding the account never resets the parser ceiling.
A parser-bound allocation cannot survive its borrowed owner:
ⓘ
use std::sync::Arc;
use structured_asn1::{Parser, memory::{Memory, MemoryAccount, Work}};
let mut scratch;
{
let parser = Parser::ber(Memory::new(Arc::new(MemoryAccount::new(1024, 1024))));
let reader = parser.read(&[], 0).unwrap();
scratch = reader.execution().vector();
scratch.try_push(42_u8).unwrap();
}
drop(scratch);Trait Implementations§
impl<'a> Copy for Execution<'a>
Source§impl Work for Execution<'_>
impl Work for Execution<'_>
Source§type Retained = Memory
type Retained = Memory
Storage ownership retained by the allocator independently of borrowed work.
Source§fn retain_storage(&self) -> Memory
fn retain_storage(&self) -> Memory
Source§fn into_storage_owner(self, retained: Memory) -> Memory
fn into_storage_owner(self, retained: Memory) -> 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, Memory)
fn with_storage_owner(&self, memory: Memory) -> (Self, Memory)
Attaches current work while moving an existing same-account owner.
The caller verifies account identity before transferring storage.
Source§fn charge_work(&self, amount: u64) -> Result<(), MemoryError>
fn charge_work(&self, amount: u64) -> Result<(), MemoryError>
Admits work before execution, against every applicable ceiling.
Source§fn work_remaining(&self) -> usize
fn work_remaining(&self) -> usize
The largest amount
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>>
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,
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 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,
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>>
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.Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Execution<'a>
impl<'a> !Send for Execution<'a>
impl<'a> !Sync for Execution<'a>
impl<'a> !UnwindSafe for Execution<'a>
impl<'a> Freeze for Execution<'a>
impl<'a> Unpin for Execution<'a>
impl<'a> UnsafeUnpin for Execution<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more