Skip to main content

SchemaRegistry

Struct SchemaRegistry 

Source
pub struct SchemaRegistry { /* private fields */ }
Expand description

Offline, reusable schema registry. A URL is an identity, never a field-name hint. Registration needs exclusive access; parsing and validation can run concurrently.

§Examples

use raster_style::{SchemaRegistry, TILE_SCHEMA_URL};
let registry = SchemaRegistry::new()?;
let style = registry.parse_json(r#"{
  "version":"3.0", "renderer":{"type":"gray","bidx":[1]},
  "extensions":["https://mapseekai.github.io/raster-style/extensions/raster/tile/v1.0.0/schema.json"],
  "raster:tile":{"format":"png"}
}"#)?;
assert!(style.validation().complete);
style.require_extension_support(&[TILE_SCHEMA_URL])?;

Implementations§

Source§

impl SchemaRegistry

Source

pub fn new() -> Result<Self>

Create an offline registry containing the core and official extension schemas.

§Errors

Returns E_CONFIG if an embedded resource cannot be initialized.

Source

pub fn register(&mut self, schema: Value) -> Result<()>

Register an immutable draft 2020-12 resource. Register referenced resources separately. Previously constructed styles retain their validation report snapshots.

§Errors

Returns a JSON/budget error for invalid input, or E_CONFIG for an invalid schema identity, draft, resource, duplicate registration or poisoned cache.

Source

pub fn resolve( &mut self, url: &str, resolver: impl FnOnce(&str) -> Result<Value>, ) -> Result<()>

Explicit resolution only; callers own network policy, allowlists, budgets and timeouts. The callback is invoked once and its returned $id must equal url exactly.

§Errors

Propagates callback and registration failures; invalid or mismatched identities return E_CONFIG.

Source

pub fn parse_json(&self, text: &str) -> Result<Style>

Parse and normalize a style without changing the input text. Unknown declarations are preserved with complete=false; this does not authorize execution.

§Errors

Returns JSON, budget, known-schema or static-semantic errors. A referenced resource missing from an available schema returns E_SCHEMA_UNRESOLVED.

Source

pub fn inspect_json(&self, text: &str) -> Result<ValidationReport>

Parse a style and return an owned snapshot of its validation completeness.

§Errors

Returns the same errors as Self::parse_json; known errors are never preserved as success.

Source

pub fn validate_json(&self, text: &str) -> Result<()>

Full validation includes all declared schemas and static cross-field semantics. Execution support must still be checked with Style::require_extension_support.

§Errors

Returns parsing/validation errors, including E_SCHEMA_UNRESOLVED when any declared schema or required reference is unavailable.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.