pub struct Schema {
pub name: String,
pub fields: HashMap<String, FieldSchema>,
pub required: Vec<String>,
pub additional_properties: bool,
}Expand description
Schema definition for document validation.
Fields§
§name: String§fields: HashMap<String, FieldSchema>§required: Vec<String>§additional_properties: boolImplementations§
Source§impl Schema
impl Schema
Sourcepub fn field(self, name: impl Into<String>, schema: FieldSchema) -> Self
pub fn field(self, name: impl Into<String>, schema: FieldSchema) -> Self
Add a field to the schema.
Sourcepub fn additional_properties(self, allow: bool) -> Self
pub fn additional_properties(self, allow: bool) -> Self
Set whether additional properties are allowed.
Sourcepub fn validate(&self, doc: &Document) -> ValidationResult
pub fn validate(&self, doc: &Document) -> ValidationResult
Validate a document against this schema.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
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
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
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