[−][src]Struct jsl::schema::Schema
An abstract representation of a JSL 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
.
Methods
impl Schema
[src]
pub fn from_parts(
defs: Option<HashMap<String, Schema>>,
form: Box<Form>,
extra: HashMap<String, Value>
) -> Schema
[src]
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.
pub fn from_serde(serde_schema: Serde) -> Result<Self, Error>
[src]
Construct a new, root schema from a Serde
.
pub fn into_serde(self) -> Serde
[src]
Convert this schema into a Serde
.
pub fn is_root(&self) -> bool
[src]
Is this schema a root schema?
Under the hood, this is entirely equivalent to checking whether
definitions().is_some()
.
pub fn definitions(&self) -> &Option<HashMap<String, Schema>>
[src]
Get the definitions associated with this schema.
If this schema is non-root, this returns None.
pub fn form(&self) -> &Form
[src]
Get the form of the schema.
pub fn extra(&self) -> &HashMap<String, Value>
[src]
Get extra data associated with this schema.
Essentially, this function returns a JSON object of properties that aren't JSL keywords, but which were included in the schema's JSON. You might use these nonstandard fields to implement custom behavior.
Trait Implementations
impl PartialEq<Schema> for Schema
[src]
impl Clone for Schema
[src]
fn clone(&self) -> Schema
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Schema
[src]
Auto Trait Implementations
impl Unpin for Schema
impl Sync for Schema
impl Send for Schema
impl RefUnwindSafe for Schema
impl UnwindSafe for Schema
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,