pub struct Struct {
pub fields: Vec<StructField>,
pub inherit: Option<String>,
}Expand description
A struct which has a number of fields
It will automatically add a termite::Node::Map field called extra_fields which holds all fields which were not captured when parsing
Fields§
§fields: Vec<StructField>A list of all the fields of the struct
inherit: Option<String>The name of a different Struct this Struct builds onto, used in Schema generation
Implementations§
Source§impl Struct
impl Struct
Sourcepub fn export_schema(
&self,
custom_types: &HashMap<String, DataType>,
dependencies: &mut HashSet<String>,
macros: &HashMap<String, SerializationModel>,
) -> Result<Object, Error>
pub fn export_schema( &self, custom_types: &HashMap<String, DataType>, dependencies: &mut HashSet<String>, macros: &HashMap<String, SerializationModel>, ) -> Result<Object, Error>
Creates a JSON schema from the struct
§Parameters
custom_types: The map of all the custom types, used to check if a type is builtin or not
dependencies: A set to add all dependencies of this struct to
macros: A map of all macros to expand default values
Sourcepub fn schema_value(
&self,
value: &SerializationModel,
custom_types: &HashMap<String, DataType>,
) -> Result<JsonValue, Error>
pub fn schema_value( &self, value: &SerializationModel, custom_types: &HashMap<String, DataType>, ) -> Result<JsonValue, Error>
Converts a serialization model value into a JSON value of the for of this type
§Parameters
value: The serialization model to convert
custom_types: All the custom types in the schema
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Struct
impl<'de> Deserialize<'de> for Struct
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
impl StructuralPartialEq for Struct
Auto Trait Implementations§
impl Freeze for Struct
impl RefUnwindSafe for Struct
impl Send for Struct
impl Sync for Struct
impl Unpin for Struct
impl UnwindSafe for Struct
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