Skip to main content

SchemaResolver

Trait SchemaResolver 

Source
pub trait SchemaResolver {
    // Required method
    fn resolve(
        &self,
        location: &str,
        target_namespace: Option<&str>,
    ) -> Result<Option<Vec<u8>>, Error>;
}
Expand description

Resolves a schema-location hint to the XSD bytes for that schema.

Two conventions matter for implementations:

  • Returning Ok(None) declines the resolution (the parser then produces a clear “could not resolve” compile error).
  • Returning Err(_) propagates an I/O failure; the parser wraps it in a SchemaCompileError.

Implementations should be cheap to clone — the parser recursively invokes them while processing nested includes.

The resolver is consumed synchronously by Schema::compile_with and never stored or sent across threads, so no Send/Sync bound is required — letting a resolver borrow a non-Sync loader for the duration of one compile.

Required Methods§

Source

fn resolve( &self, location: &str, target_namespace: Option<&str>, ) -> Result<Option<Vec<u8>>, Error>

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§