pub enum Schema {
Bool(bool),
Object(SchemaObject),
}
Expand description
A JSON Schema.
Variants§
Bool(bool)
A trivial boolean JSON Schema.
The schema true
matches everything (always passes validation), whereas the schema false
matches nothing (always fails validation).
Object(SchemaObject)
A JSON Schema object.
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new_ref(reference: String) -> Self
pub fn new_ref(reference: String) -> Self
Creates a new $ref
schema.
The given reference string should be a URI reference. This will usually be a JSON Pointer in URI Fragment representation.
Sourcepub fn is_ref(&self) -> bool
pub fn is_ref(&self) -> bool
Returns true
if self
is a $ref
schema.
If self
is a SchemaObject
with Some
reference
set, this returns true
.
Otherwise, returns false
.
Sourcepub fn as_object(&self) -> Option<&SchemaObject>
pub fn as_object(&self) -> Option<&SchemaObject>
Gets a reference to the inner schema object if this schema is a JSON Schema object.
Otherwise, None
is returned.
Sourcepub fn as_object_mut(&mut self) -> Option<&mut SchemaObject>
pub fn as_object_mut(&mut self) -> Option<&mut SchemaObject>
Gets a mutable reference to the inner schema object if this schema is a JSON Schema object.
Otherwise, None
is returned.
Sourcepub fn into_object(self) -> SchemaObject
pub fn into_object(self) -> SchemaObject
Converts the given schema (if it is a boolean schema) into an equivalent schema object.
If the given schema is already a schema object, this has no effect.