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<'_>
impl Octets<'_>
Sourcepub 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>>
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.
Sourcepub 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>>
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>
impl<'a> Octets<'a>
Sourcepub fn read(
parent: &Reader<'a>,
element: &Element<'a>,
field: &'static str,
) -> Result<Self>
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
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
The logical octet count, recorded during parsing without a later scan.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the logical content is empty, including constructed empty input.
Sourcepub fn as_one(&self) -> Option<&'a [u8]>
pub fn as_one(&self) -> Option<&'a [u8]>
The borrowed bytes when the logical value occupies one original range.
Sourcepub fn copy_in(
&self,
parent: &Reader<'_>,
field: &'static str,
at: u64,
) -> Result<OwnedVec<u8>>
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.