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>
impl<'a, X: Xml, W: Work> Access<'a, X, W>
Sourcepub fn new(
xml: &'a X,
snapshot: Snapshot<X::Document, X::Generation>,
execution: &'a W,
) -> Self
pub fn new( xml: &'a X, snapshot: Snapshot<X::Document, X::Generation>, execution: &'a W, ) -> Self
Attaches the expected original snapshot and current operation.
Sourcepub fn snapshot(&self) -> Snapshot<X::Document, X::Generation>
pub fn snapshot(&self) -> Snapshot<X::Document, X::Generation>
The source snapshot associated with node locations and selection evidence.
Sourcepub fn execution(&self) -> &W
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.
Sourcepub fn children(&self, parent: X::Id) -> Children<'_, 'a, X, W> ⓘ
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.
Sourcepub fn inspect<R>(
&self,
node: X::Id,
visitor: impl for<'view> FnOnce(Node<'view>) -> R,
) -> AccessResult<R, X>
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,
})
}Sourcepub fn has_name(&self, node: X::Id, expected: Name<'_>) -> AccessResult<bool, X>
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.
Sourcepub fn attribute<R>(
&self,
node: X::Id,
name: Name<'_>,
visitor: impl for<'view> FnOnce(Option<&'view str>) -> R,
) -> AccessResult<R, X>
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.
Sourcepub fn first_child(&self, parent: X::Id) -> AccessResult<Option<X::Id>, X>
pub fn first_child(&self, parent: X::Id) -> AccessResult<Option<X::Id>, X>
Begins a direct-child traversal, admitting even the empty-list query.
Sourcepub fn next_sibling(
&self,
parent: X::Id,
node: X::Id,
) -> AccessResult<Option<X::Id>, X>
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.