pub trait Schema: Sized {
Show 18 methods
// Required methods
fn description(&self) -> Option<&str>;
fn reference(&self) -> Option<&str>;
fn data_type(&self) -> Option<DataType>;
fn format(&self) -> Option<&DataTypeFormat>;
fn items(&self) -> Option<&Resolvable<Self>>;
fn items_mut(&mut self) -> Option<&mut Resolvable<Self>>;
fn additional_properties(&self) -> Option<&Either<bool, Resolvable<Self>>>;
fn additional_properties_mut(
&mut self,
) -> Option<&mut Either<bool, Resolvable<Self>>>;
fn properties(&self) -> Option<&BTreeMap<String, Resolvable<Self>>>;
fn properties_mut(
&mut self,
) -> Option<&mut BTreeMap<String, Resolvable<Self>>>;
fn required_properties(&self) -> Option<&BTreeSet<String>>;
fn enum_variants(&self) -> Option<&[Value]>;
fn set_reference(&mut self, ref_: String);
fn set_cyclic(&mut self, cyclic: bool);
fn is_cyclic(&self) -> bool;
fn name(&self) -> Option<&str>;
fn set_name(&mut self, name: &str);
// Provided method
fn contains_any(&self) -> bool { ... }
}
Expand description
Interface for the Schema
object.
This is only used for resolving the definitions.
NOTE: Don’t implement this by yourself! Please use the #[api_v2_schema]
proc macro attribute instead.
Required Methods§
sourcefn description(&self) -> Option<&str>
fn description(&self) -> Option<&str>
Description for this schema, if any (description
field).
sourcefn format(&self) -> Option<&DataTypeFormat>
fn format(&self) -> Option<&DataTypeFormat>
Data type format used by this schema, if any (format
field).
sourcefn items(&self) -> Option<&Resolvable<Self>>
fn items(&self) -> Option<&Resolvable<Self>>
Schema for array definitions, if any (items
field).
sourcefn items_mut(&mut self) -> Option<&mut Resolvable<Self>>
fn items_mut(&mut self) -> Option<&mut Resolvable<Self>>
Mutable access to the items
field, if it exists.
sourcefn additional_properties(&self) -> Option<&Either<bool, Resolvable<Self>>>
fn additional_properties(&self) -> Option<&Either<bool, Resolvable<Self>>>
Value schema for maps (additional_properties
field).
sourcefn additional_properties_mut(
&mut self,
) -> Option<&mut Either<bool, Resolvable<Self>>>
fn additional_properties_mut( &mut self, ) -> Option<&mut Either<bool, Resolvable<Self>>>
Mutable access to additional_properties
field, if it’s a map.
sourcefn properties(&self) -> Option<&BTreeMap<String, Resolvable<Self>>>
fn properties(&self) -> Option<&BTreeMap<String, Resolvable<Self>>>
Map of names and schema for properties, if it’s an object (properties
field)
sourcefn properties_mut(&mut self) -> Option<&mut BTreeMap<String, Resolvable<Self>>>
fn properties_mut(&mut self) -> Option<&mut BTreeMap<String, Resolvable<Self>>>
Mutable access to properties
field.
sourcefn required_properties(&self) -> Option<&BTreeSet<String>>
fn required_properties(&self) -> Option<&BTreeSet<String>>
Returns the required properties (if any) for this object.
sourcefn enum_variants(&self) -> Option<&[Value]>
fn enum_variants(&self) -> Option<&[Value]>
Enum variants in this schema (if any). It’s serde_json::Value
because:
- Enum variants are allowed to have any type of value.
serde_json::Value
works for both JSON and YAML.
sourcefn set_reference(&mut self, ref_: String)
fn set_reference(&mut self, ref_: String)
Set the reference to this schema.
sourcefn set_cyclic(&mut self, cyclic: bool)
fn set_cyclic(&mut self, cyclic: bool)
Set whether this definition is cyclic. This is done by the resolver.
sourcefn is_cyclic(&self) -> bool
fn is_cyclic(&self) -> bool
Returns whether this definition is cyclic.
NOTE: This is not part of the schema object, but it’s
set by the resolver using set_cyclic
for codegen.
Provided Methods§
sourcefn contains_any(&self) -> bool
fn contains_any(&self) -> bool
Returns whether this definition “is” or “has” Any
type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.