Skip to main content

Access

Struct Access 

Source
pub struct Access<'a, X: Xml, W: Work> { /* private fields */ }
Expand description

One snapshot and current operation shared by all scoped XML queries.

This guard checks the snapshot before and after every successful callback. The adapter must also check at actual access, so these checks do not replace owner synchronization or immutable-view guarantees. No clone, allocation or reference-count increment is required to construct the guard.

Implementations§

Source§

impl<'a, X: Xml, W: Work> Access<'a, X, W>

Source

pub fn new( xml: &'a X, snapshot: Snapshot<X::Document, X::Generation>, execution: &'a W, ) -> Self

Attaches the expected original snapshot and current operation.

Source

pub fn snapshot(&self) -> Snapshot<X::Document, X::Generation>

The source snapshot associated with node locations and selection evidence.

Source

pub fn execution(&self) -> &W

Borrows the actual current execution used by this access boundary. Provider/resolver lexical scans and owned results must be admitted here, rather than on an earlier source/storage account. No clone, allocation or account/reference-count change occurs. The borrow cannot outlive this access handle and does not expose the XML owner’s internal DOM.

Source

pub fn children(&self, parent: X::Id) -> Children<'_, 'a, X, W> ⓘ

Traverses direct element children, skipping comments and XML whitespace.

Character data is rejected rather than silently dropped. Each skipped node is admitted and checked in the same operation, so an empty result cannot bypass a large whitespace/comment fan-out. Construction allocates nothing. The first error is returned once, then iteration is fused.

Source

pub fn inspect<R>( &self, node: X::Id, visitor: impl for<'view> FnOnce(Node<'view>) -> R, ) -> AccessResult<R, X>

Inspects one node without leaking callback-local XML borrows.

ⓘ
use structured_xades::xml::{Access, AccessError, Node, Xml};
use structured_asn1::memory::Work;
fn escape<'a, X: Xml, W: Work>(access: &Access<'a, X, W>, node: X::Id)
    -> Result<Option<&'a str>, AccessError<X::Error, X::Id>>
{
    access.inspect(node, |value| match value {
        Node::Text(text) => Some(text),
        _ => None,
    })
}
Source

pub fn has_name(&self, node: X::Id, expected: Name<'_>) -> AccessResult<bool, X>

Compares an element’s expanded name with admission before each byte scan.

A different node kind or name length needs no string scan. Namespace names are compared exactly, without URI resolution or normalization.

Source

pub fn attribute<R>( &self, node: X::Id, name: Name<'_>, visitor: impl for<'view> FnOnce(Option<&'view str>) -> R, ) -> AccessResult<R, X>

Reads a normalized attribute, preserving absence versus an empty value.

Source

pub fn first_child(&self, parent: X::Id) -> AccessResult<Option<X::Id>, X>

Begins a direct-child traversal, admitting even the empty-list query.

Source

pub fn next_sibling( &self, parent: X::Id, node: X::Id, ) -> AccessResult<Option<X::Id>, X>

Advances within the same direct-child list in original order.

Trait Implementations§

Source§

impl<X: Xml, W: Work> Query for Access<'_, X, W>

Source§

type Id = <X as Xml>::Id

Original node identity.
Source§

type Document = <X as Xml>::Document

Stable document identity.
Source§

type Generation = <X as Xml>::Generation

Exact document generation.
Source§

type Work = W

Current execution funding this query.
Source§

fn snapshot(&self) -> Snapshot<X::Document, X::Generation>

The expected source snapshot of every fact checked in this query.
Source§

fn execution(&self) -> &W

The current execution; storage and work for results are admitted here.
Source§

fn admit(&self, node: X::Id, units: u64) -> Result<(), ScopeError<X::Id>>

Requires the live source at the expected snapshot, admits units of work, and requires the snapshot again.
Source§

fn equal(&self, left: Self::Id, right: Self::Id) -> Result<bool, MemoryError>

Compares two identities after admitting their complete HashWork.

Auto Trait Implementations§

§

impl<'a, X, W> Freeze for Access<'a, X, W>

§

impl<'a, X, W> RefUnwindSafe for Access<'a, X, W>

§

impl<'a, X, W> Send for Access<'a, X, W>
where &'a X: Send, Snapshot<<X as Xml>::Document, <X as Xml>::Generation>: Send, &'a W: Send,

§

impl<'a, X, W> Sync for Access<'a, X, W>
where &'a X: Sync, Snapshot<<X as Xml>::Document, <X as Xml>::Generation>: Sync, &'a W: Sync,

§

impl<'a, X, W> Unpin for Access<'a, X, W>
where &'a X: Unpin, Snapshot<<X as Xml>::Document, <X as Xml>::Generation>: Unpin, &'a W: Unpin,

§

impl<'a, X, W> UnsafeUnpin for Access<'a, X, W>

§

impl<'a, X, W> UnwindSafe for Access<'a, X, W>

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.