silk.json.schema_resolver.
Caller-replaceable JSON Schema document resolution during compilation.
Details#
Provide SchemaResolver to Schema.compile. The compiler requests absolute, fragment-free
retrieval URIs and owns returned trees. Validation never calls this service. No filesystem
or network provider is installed implicitly. Providers may bind their own I/O dependencies.
Use SchemaRegistry for reusable, explicitly registered in-memory documents.
Import as SchemaResolver with import silk.json.schema_resolver { SchemaResolver }.
Public declarations: 3.
SchemaResolutionError#
pub struct SchemaResolutionErrorAn operational provider failure, distinct from an unavailable document or invalid schema.
Field uri#
pub uri: StringAbsolute retrieval URI whose resolution failed; owned independently of the provider.
Field detail#
pub detail: StringProvider-supplied explanation of the failure.
SchemaResolver#
pub service SchemaResolverResolves external schemas and custom metaschemas for Schema.compile.
Details#
Implementations return an owned tree, transferring it to the compiler. Each requested retrieval URI is cached for one compilation; indexed local resources need no provider call. A provider can be dropped after compilation, before validation.
Operation resolve#
effect fn resolve(uri: string) -> Option<Value>
! SchemaResolutionError | OutOfMemoryError ? &mut SchemaResolver | &mut AllocatorResolves an absolute URI without a fragment. None means the document is unavailable.
Errors#
SchemaResolutionErrorfor provider failures, such as denied or failed I/O.OutOfMemoryErrorif the provider cannot allocate the returned document.
SchemaRegistry#
pub struct SchemaRegistryAn explicit in-memory resolver that owns registered schemas and is reusable across compilations. Resolution copies the selected document once, preserving exact numbers and object order.
Implementation SchemaRegistry#
impl SchemaRegistryAssociated function make#
pub fn make() -> SchemaRegistryReturns an empty provider; every URI is unavailable until a schema is added.
Method add#
pub effect fn add(self: &mut Self, uri: string, schema: Value) -> ()
! OutOfMemoryError ? &mut AllocatorRegisters schema under the absolute, fragment-free retrieval uri, taking ownership.
An existing entry with the same URI is replaced. Resolution also recognizes a document's
absolute $id or draft-4 id after removing its fragment.
Errors#
OutOfMemoryErrorif the registry cannot store the URI or entry.
Implementation SchemaResolver for SchemaRegistry#
impl SchemaResolver for SchemaRegistryOperation resolve#
effect fn resolve(self: &mut Self, uri: string) -> Option<Value>
! SchemaResolutionError | OutOfMemoryError ? &mut AllocatorCategory: Data formats.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.