silk.json.schema_metas.

Offline official JSON Schema meta-schemas for drafts 4, 6, 7, 2019-09, and 2020-12.

When to use#

Use SchemaMetas.documents to supply the official meta-schema resources when compiling schemas that reference them. Add borrowed views of the returned documents to the resource registry passed to silk.json.schema.Schema.compile; keep the documents alive while the compiled schema is used. No network requests are made.

Import as SchemaMetas with import silk.json.schema_metas { SchemaMetas }.

Public declarations: 2.

MetaDocument#

silk
pub struct MetaDocument

An owned official meta-schema and its canonical retrieval URI.

Field uri#

silk
pub uri: String

Canonical resource URI, without an empty fragment.

Field schema#

silk
pub schema: Value

Exact JSON data model of the official meta-schema.

SchemaMetas#

silk
pub struct SchemaMetas

Constructs the offline official meta-schema resource collection.

Implementation SchemaMetas#

silk
impl SchemaMetas

Associated function documents#

silk
pub effect fn documents() -> List<MetaDocument>
    ! JsonError | OutOfMemoryError ? &mut Allocator

Parses the embedded official meta-schemas for drafts 4, 6, 7, 2019-09, and 2020-12.

Details#

The returned collection owns its trees. Pass borrowed Resource views to Schema.compile and retain this collection for the lifetime of compiled schemas. It includes the individual vocabulary meta-schemas, including the optional 2020-12 format-assertion vocabulary. Nothing is downloaded and no schemas are read from the filesystem.

Errors#

  • OutOfMemoryError if the allocator cannot supply the collection or parsed trees.

  • JsonError if an embedded document cannot be parsed.

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