pub struct Catalog { /* private fields */ }Expand description
In-memory representation of one or more parsed XML catalog files.
Construct with load_default to use the libxml2-compatible
discovery rules, or with [from_files] / [parse] when you
know the catalog locations explicitly.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn resolve<'a>(
&'a self,
public_id: Option<&str>,
system_id: Option<&str>,
) -> Option<Cow<'a, str>>
pub fn resolve<'a>( &'a self, public_id: Option<&str>, system_id: Option<&str>, ) -> Option<Cow<'a, str>>
Look up a (publicId, systemId) pair against the catalog.
Resolution follows OASIS § 7: SYSTEM exact → rewriteSystem
→ delegateSystem → PUBLIC exact (per prefer) →
delegatePublic → nextCatalog chains. Returns the catalog’s
URI for the entity, or None if no entry matched anywhere
in the chain.
The result is a Cow so direct <public> / <system>
matches return a borrow into the catalog (zero allocation)
while rewrite entries return the synthesised string owned.
Callers that need to own the URI past the catalog’s lifetime
can call .into_owned().
Sourcepub fn resolve_uri<'a>(&'a self, uri: &str) -> Option<Cow<'a, str>>
pub fn resolve_uri<'a>(&'a self, uri: &str) -> Option<Cow<'a, str>>
<uri> lookup — resolve a generic URI alias. Distinct from
<system>: the OASIS spec keeps the two namespaces
separate. Used by XInclude / XSLT consumers that want a
catalog-style mapping without going through DTD’s
PUBLIC/SYSTEM mechanism.
As with resolve, the result is a Cow —
direct <uri> matches borrow; <rewriteUri> matches own.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Number of entries in the catalog. Counts every entry, including rewrite/delegate/next ones. Used in tests and diagnostics.