Skip to main content

parse_schema_document

Function parse_schema_document 

Source
pub fn parse_schema_document(
    protocol: &str,
    doc: &Value,
) -> Result<Schema, ProtocolError>
Expand description

Parse a single JSON schema document into a Schema, dispatching on protocol name.

This is the generic entry point that exposes every JSON-document schema parser through one call, so a binding forwards a protocol string here rather than reaching each protocol’s parser directly. Protocols whose source is text rather than JSON (SQL DDL, GraphQL SDL, .proto, CDDL, CQL, Cypher, ASN.1, Bond, FlatBuffers, CoNLL-U) are served by parse_schema_source instead.

The protocol argument is matched against each protocol’s canonical Protocol::name (hyphenated). An underscore is normalized to a hyphen first, so the underscore registry keys that crate callers list (iso_space, msgpack_schema, …) resolve too; uima is accepted as an alias of its canonical uima-cas.

§Errors

Returns ProtocolError::Parse if no JSON-document parser is registered for protocol (a text-source protocol, or an unknown name), or the protocol’s own error if the document is malformed.