pub struct ConstrainedType {
pub data_type: String,
pub constraints: Vec<Constraint>,
}Expand description
A constrained type, wraps any other type and adds constraints onto them
Fields§
§data_type: StringThe type that is constrained
constraints: Vec<Constraint>All extra constraints for the type, must be written as an expression where the constrained value is denoted x
Implementations§
Source§impl ConstrainedType
impl ConstrainedType
Sourcepub fn export_schema(
&self,
custom_types: &HashMap<String, DataType>,
dependencies: &mut HashSet<String>,
) -> Result<Object, Error>
pub fn export_schema( &self, custom_types: &HashMap<String, DataType>, dependencies: &mut HashSet<String>, ) -> Result<Object, Error>
Creates a JSON schema from the constrained type
§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 constrained type to
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 Clone for ConstrainedType
impl Clone for ConstrainedType
Source§fn clone(&self) -> ConstrainedType
fn clone(&self) -> ConstrainedType
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ConstrainedType
impl Debug for ConstrainedType
Source§impl<'de> Deserialize<'de> for ConstrainedType
impl<'de> Deserialize<'de> for ConstrainedType
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 ConstrainedType
impl PartialEq for ConstrainedType
Source§impl Serialize for ConstrainedType
impl Serialize for ConstrainedType
impl StructuralPartialEq for ConstrainedType
Auto Trait Implementations§
impl Freeze for ConstrainedType
impl RefUnwindSafe for ConstrainedType
impl Send for ConstrainedType
impl Sync for ConstrainedType
impl Unpin for ConstrainedType
impl UnsafeUnpin for ConstrainedType
impl UnwindSafe for ConstrainedType
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