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#

silk
pub struct SchemaResolutionError

An operational provider failure, distinct from an unavailable document or invalid schema.

Field uri#

silk
pub uri: String

Absolute retrieval URI whose resolution failed; owned independently of the provider.

Field detail#

silk
pub detail: String

Provider-supplied explanation of the failure.

SchemaResolver#

silk
pub service SchemaResolver

Resolves 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#

silk
effect fn resolve(uri: string) -> Option<Value>
    ! SchemaResolutionError | OutOfMemoryError ? &mut SchemaResolver | &mut Allocator

Resolves an absolute URI without a fragment. None means the document is unavailable.

Errors#

  • SchemaResolutionError for provider failures, such as denied or failed I/O.

  • OutOfMemoryError if the provider cannot allocate the returned document.

SchemaRegistry#

silk
pub struct SchemaRegistry

An 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#

silk
impl SchemaRegistry

Associated function make#

silk
pub fn make() -> SchemaRegistry

Returns an empty provider; every URI is unavailable until a schema is added.

Method add#

silk
pub effect fn add(self: &mut Self, uri: string, schema: Value) -> ()
    ! OutOfMemoryError ? &mut Allocator

Registers 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#

  • OutOfMemoryError if the registry cannot store the URI or entry.

Implementation SchemaResolver for SchemaRegistry#

silk
impl SchemaResolver for SchemaRegistry

Operation resolve#

silk
effect fn resolve(self: &mut Self, uri: string) -> Option<Value>
    ! SchemaResolutionError | OutOfMemoryError ? &mut Allocator

Category: 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.

View the source of this page