pub struct Schema { /* private fields */ }Expand description
An abstract representation of a JDDF schema.
This struct is meant for use by validators, code generators, or other
high-level processors of schemas. For serialization and deserialization of
schemas, instead use Serde.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn from_parts(
defs: Option<HashMap<String, Schema>>,
form: Box<Form>,
extra: HashMap<String, Value>,
) -> Schema
pub fn from_parts( defs: Option<HashMap<String, Schema>>, form: Box<Form>, extra: HashMap<String, Value>, ) -> Schema
Construct a new schema from its constituent parts.
defs should be present (i.e. not None) if and only if the
constructed schema is a root one. This invariant is not enforced, but
many users of this crate will presume that root schemas have definitions
they can unwrap. Likewise, some tooling will assume that any schema
which has non-None definitions are root schemas.
Sourcepub fn from_serde(serde_schema: Serde) -> Result<Self, Error>
pub fn from_serde(serde_schema: Serde) -> Result<Self, Error>
Construct a new, root schema from a Serde.
Sourcepub fn into_serde(self) -> Serde
pub fn into_serde(self) -> Serde
Convert this schema into a Serde.
Sourcepub fn is_root(&self) -> bool
pub fn is_root(&self) -> bool
Is this schema a root schema?
Under the hood, this is entirely equivalent to checking whether
definitions().is_some().
Sourcepub fn definitions(&self) -> &Option<HashMap<String, Schema>>
pub fn definitions(&self) -> &Option<HashMap<String, Schema>>
Get the definitions associated with this schema.
If this schema is non-root, this returns None.
Sourcepub fn extra(&self) -> &HashMap<String, Value>
pub fn extra(&self) -> &HashMap<String, Value>
Get extra data associated with this schema.
Essentially, this function returns a JSON object of properties that aren’t JDDF keywords, but which were included in the schema’s JSON. You might use these nonstandard fields to implement custom behavior.