pub struct SchemaDefinition {
pub format: String,
pub resource: Option<ExternalResourceDefinition>,
pub document: Option<Value>,
}Expand description
Represents the definition of a schema
Fields§
§format: StringGets/sets the schema’s format. Defaults to ‘json’. The (optional) version of the format can be set using {format}:{version}.
resource: Option<ExternalResourceDefinition>Gets/sets the schema’s external resource, if any. Required if document has not been set.
document: Option<Value>Gets/sets the inline definition of the schema to use. Required if resource has not been set.
Implementations§
Source§impl SchemaDefinition
impl SchemaDefinition
Sourcepub fn with_document(format: &str, document: Value) -> Self
pub fn with_document(format: &str, document: Value) -> Self
Creates a new schema definition with an inline document
Sourcepub fn with_resource(format: &str, resource: ExternalResourceDefinition) -> Self
pub fn with_resource(format: &str, resource: ExternalResourceDefinition) -> Self
Creates a new schema definition with an external resource
Sourcepub fn validate(&self) -> Result<(), SchemaValidationError>
pub fn validate(&self) -> Result<(), SchemaValidationError>
Validates that the schema definition is valid (document XOR resource)
Sourcepub fn is_document(&self) -> bool
pub fn is_document(&self) -> bool
Gets whether this schema uses an inline document
Sourcepub fn is_resource(&self) -> bool
pub fn is_resource(&self) -> bool
Gets whether this schema uses an external resource
Trait Implementations§
Source§impl Clone for SchemaDefinition
impl Clone for SchemaDefinition
Source§fn clone(&self) -> SchemaDefinition
fn clone(&self) -> SchemaDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SchemaDefinition
impl Debug for SchemaDefinition
Source§impl Default for SchemaDefinition
impl Default for SchemaDefinition
Source§impl<'de> Deserialize<'de> for SchemaDefinition
impl<'de> Deserialize<'de> for SchemaDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for SchemaDefinition
impl PartialEq for SchemaDefinition
Source§impl Serialize for SchemaDefinition
impl Serialize for SchemaDefinition
impl StructuralPartialEq for SchemaDefinition
Auto Trait Implementations§
impl Freeze for SchemaDefinition
impl RefUnwindSafe for SchemaDefinition
impl Send for SchemaDefinition
impl Sync for SchemaDefinition
impl Unpin for SchemaDefinition
impl UnsafeUnpin for SchemaDefinition
impl UnwindSafe for SchemaDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more