pub trait EntityResolver:
Send
+ Sync
+ Debug {
// Required method
fn resolve(
&self,
public_id: Option<&str>,
system_id: &str,
base_uri: Option<&str>,
) -> Result<Vec<u8>, ResolveError>;
}Expand description
Resolves external XML resources by their public/system identifier. Implementors decide what URLs are loadable, where the bytes come from, and what security checks apply.
Implementations must be Send + Sync so the resolver can be
shared across threads or used from async contexts.
Required Methods§
Sourcefn resolve(
&self,
public_id: Option<&str>,
system_id: &str,
base_uri: Option<&str>,
) -> Result<Vec<u8>, ResolveError>
fn resolve( &self, public_id: Option<&str>, system_id: &str, base_uri: Option<&str>, ) -> Result<Vec<u8>, ResolveError>
Resolve an external entity reference.
public_id: the FPI (formal public identifier) from a PUBLIC declaration, if present. Catalog-based resolvers try this first per OASIS § 7.1.1.system_id: an already-absolute SYSTEM URL. The parser performs base-URI resolution (XML 1.0 § 4.2.2 + errata E18) before calling — relative literals in the DTD are joined against the document URL for general-entity declarations and against the containing entity’s URL for parameter-entity declarations. Resolvers that don’t consult a catalog use this to locate the bytes; no URI joining is required from the implementation.base_uri: the base URI the parser used when pre-joining the SYSTEM identifier. Informational — most resolvers can ignore it. Catalog-aware resolvers may consult it when the catalog lookup falls back to filesystem (e.g. to scope a security check), and resolvers that want to log or report the original document context can use it. Correctness does not require consuming this parameter.
Returns the entity’s bytes on success. Use
ResolveError::Refused when the resolver chose not to
load (security policy denied) versus
ResolveError::Io when loading failed for an external
reason.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".