pub struct SchemaBuilder { /* private fields */ }
Expand description
A Schema
builder.
Implementations§
Source§impl SchemaBuilder
impl SchemaBuilder
Sourcepub fn build_root<T: Schematic>() -> Schema
pub fn build_root<T: Schematic>() -> Schema
Generate a schema from the provided type.
Sourcepub fn set_deprecated(&mut self, value: impl AsRef<str>)
pub fn set_deprecated(&mut self, value: impl AsRef<str>)
Mark this schema as deprecated.
Sourcepub fn set_description(&mut self, value: impl AsRef<str>)
pub fn set_description(&mut self, value: impl AsRef<str>)
Add a description for this schema.
Sourcepub fn set_type(&mut self, value: SchemaType)
pub fn set_type(&mut self, value: SchemaType)
Set the type of schema.
Sourcepub fn set_type_and_build(&mut self, value: SchemaType) -> Schema
pub fn set_type_and_build(&mut self, value: SchemaType) -> Schema
Set the type of schema and then build it.
Sourcepub fn boolean(&mut self, value: BooleanType) -> Schema
pub fn boolean(&mut self, value: BooleanType) -> Schema
Build a boolean type.
Sourcepub fn boolean_default(&mut self) -> Schema
pub fn boolean_default(&mut self) -> Schema
Build a boolean type with default settings.
Sourcepub fn enumerable(&mut self, value: EnumType) -> Schema
pub fn enumerable(&mut self, value: EnumType) -> Schema
Build an enum type.
Sourcepub fn float32_default(&mut self) -> Schema
pub fn float32_default(&mut self) -> Schema
Build a 32bit float type with default settings.
Sourcepub fn float64_default(&mut self) -> Schema
pub fn float64_default(&mut self) -> Schema
Build a 64bit float type with default settings.
Sourcepub fn integer(&mut self, value: IntegerType) -> Schema
pub fn integer(&mut self, value: IntegerType) -> Schema
Build an integer type.
Sourcepub fn literal(&mut self, value: LiteralType) -> Schema
pub fn literal(&mut self, value: LiteralType) -> Schema
Build a literal type.
Sourcepub fn literal_value(&mut self, value: LiteralValue) -> Schema
pub fn literal_value(&mut self, value: LiteralValue) -> Schema
Build a literal type with a value.
Sourcepub fn nest(&self) -> SchemaBuilder
pub fn nest(&self) -> SchemaBuilder
Build a nested Schema
by cloning another builder.
Sourcepub fn nullable(&mut self, value: impl Into<Schema>) -> Schema
pub fn nullable(&mut self, value: impl Into<Schema>) -> Schema
Build a schema that is also nullable (uses a union).
Sourcepub fn object(&mut self, value: ObjectType) -> Schema
pub fn object(&mut self, value: ObjectType) -> Schema
Build an object type.
Sourcepub fn string(&mut self, value: StringType) -> Schema
pub fn string(&mut self, value: StringType) -> Schema
Build a string type.
Sourcepub fn string_default(&mut self) -> Schema
pub fn string_default(&mut self) -> Schema
Build a string type with default settings.
Sourcepub fn structure(&mut self, value: StructType) -> Schema
pub fn structure(&mut self, value: StructType) -> Schema
Build a struct type.
Sourcepub fn infer_as_nested<T: Schematic>(&self) -> Schema
pub fn infer_as_nested<T: Schematic>(&self) -> Schema
Sourcepub fn infer_with_default<T: Schematic>(&self, default: LiteralValue) -> Schema
pub fn infer_with_default<T: Schematic>(&self, default: LiteralValue) -> Schema
Methods from Deref<Target = SchemaType>§
Sourcepub fn get_default(&self) -> Option<&LiteralValue>
pub fn get_default(&self) -> Option<&LiteralValue>
Return a default
value from the inner schema type.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Return true if the schema is nullable (a union with a null).
Sourcepub fn is_reference(&self) -> bool
pub fn is_reference(&self) -> bool
Return true if the schema is a reference.
Sourcepub fn set_default(&mut self, default: LiteralValue)
pub fn set_default(&mut self, default: LiteralValue)
Set the default
of the inner schema type.
Sourcepub fn add_field(&mut self, key: &str, value: impl Into<SchemaField>)
pub fn add_field(&mut self, key: &str, value: impl Into<SchemaField>)
Add a field to the type if it’s a struct.
Trait Implementations§
Source§impl Clone for SchemaBuilder
impl Clone for SchemaBuilder
Source§fn clone(&self) -> SchemaBuilder
fn clone(&self) -> SchemaBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more