Skip to main content

Octets

Struct Octets 

Source
pub struct Octets<'a> { /* private fields */ }
Expand description

Borrowed logical octets with independently accounted segment metadata.

Primitive content stays inline and allocates no catalogue. Constructed BER content retains its original disjoint ranges, flattened only as metadata. The catalogue can outlive the producing reader; its bytes remain borrowed.

Implementations§

Source§

impl Octets<'_>

Source

pub fn with_nested_reader<R, E>( &self, parent: &Reader<'_>, encoding: Encoding, field: &'static str, callback: impl for<'scope> FnOnce(&mut Reader<'scope>, &SourceMap) -> Result<R, E>, ) -> Result<R, ContentError<E>>

Decodes carried bytes without letting a temporary joined buffer escape.

One fragment is borrowed; several are explicitly materialized. The original parser, carrying depth, cumulative local ceiling and current aggregate execution survive. R and E cannot borrow the scoped reader, model or joined bytes. Owned outputs must admit their own retained copies. Mapping metadata and joins are admitted before invoking the callback. The content must use original document coordinates. For content decoded inside a scoped mapped reader, use Self::with_nested_reader_mapped.

Source

pub fn with_nested_reader_mapped<R, E>( &self, parent: &Reader<'_>, source: &SourceMap, encoding: Encoding, field: &'static str, callback: impl for<'scope> FnOnce(&mut Reader<'scope>, &SourceMap) -> Result<R, E>, ) -> Result<R, ContentError<E>>

Decodes content inside an existing source context, composing provenance.

Supply the context that produced this content. Parent logical ranges are flattened to actual physical ranges before any callback; retained errors borrow neither the parent map nor its temporary buffer. Even a borrowed single piece can have disjoint physical provenance. The carrier is a physical enclosure including gaps, not a fabricated contiguous encoding.

Source§

impl<'a> Octets<'a>

Source

pub fn read_ia5( parent: &Reader<'a>, element: &Element<'a>, field: &'static str, ) -> Result<Self>

Reads logical IA5String contents through the SAME iterative base-string walker. BER constructed strings carry OCTET STRING fragments (X.690 §8.23.3); DER remains primitive. ASCII validation is admitted before every content scan, and original fragment spans are preserved without joining. https://www.itu.int/rec/T-REC-X.690-202102-I/en

Source

pub fn read( parent: &Reader<'a>, element: &Element<'a>, field: &'static str, ) -> Result<Self>

Reads an OCTET STRING using the original parser’s encoding and ceilings.

X.690 §8.7 permits constructed BER strings composed of OCTET STRING fragments. The iterative traversal preserves inherited depth and source positions, admitting frame/catalogue growth before allocation. A DER reader still refuses constructed forms under its own encoding contract. https://www.itu.int/rec/T-REC-X.690-202102-I/en

Source

pub fn pieces(&self) -> &[Piece<'a>]

The original primitive content ranges in logical order.

Source

pub fn len(&self) -> usize

The logical octet count, recorded during parsing without a later scan.

Source

pub fn is_empty(&self) -> bool

Whether the logical content is empty, including constructed empty input.

Source

pub fn span(&self) -> Span

The original whole carrying element, including its tag and length.

Source

pub fn as_one(&self) -> Option<&'a [u8]>

The borrowed bytes when the logical value occupies one original range.

Source

pub fn copy_in( &self, parent: &Reader<'_>, field: &'static str, at: u64, ) -> Result<OwnedVec<u8>>

Copies logical content into independently retained accounted storage.

This is an explicit materialization; inspection can keep using borrowed ranges, and an already owned result should be moved instead of copied. The original producing session is required before any admission or scan. Metadata traversal, exact capacity and each copy use both its local and current aggregate ceilings. The result retains charge after reader drop. field and at locate the actual enclosing operation, including an empty constructed value. Refusal releases partial output, not the source.

Trait Implementations§

Source§

impl<'a> Debug for Octets<'a>

Source§

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

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

impl Source for &Octets<'_>

Source§

type Error = SourceError

The original acquisition failure, distinct from a signature mismatch.
Source§

fn stream<W: Work>( &mut self, receiver: &mut impl Receiver, execution: &W, ) -> Result<(), Self::Error>

Feeds every chunk once, returning an error for an incomplete source.

Auto Trait Implementations§

§

impl<'a> !Freeze for Octets<'a>

§

impl<'a> !RefUnwindSafe for Octets<'a>

§

impl<'a> !Send for Octets<'a>

§

impl<'a> !Sync for Octets<'a>

§

impl<'a> !UnwindSafe for Octets<'a>

§

impl<'a> Unpin for Octets<'a>

§

impl<'a> UnsafeUnpin for Octets<'a>

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> 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, 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.