Enum Form

Source
pub enum Form {
    Empty,
    Ref(String),
    Type(Type),
    Enum(HashSet<String>),
    Elements(Schema),
    Properties {
        required: HashMap<String, Schema>,
        optional: HashMap<String, Schema>,
        allow_additional: bool,
        has_required: bool,
    },
    Values(Schema),
    Discriminator(String, HashMap<String, Schema>),
}
Expand description

The various forms which a schema may take on, and their respective data.

Variants§

§

Empty

The empty form.

This schema accepts all data.

§

Ref(String)

The ref form.

This schema refers to another schema, and does whatever that other schema does. The contained string is the name of the definition of the referred-to schema – it is an index into the defs of the root schema.

§

Type(Type)

The type form.

This schema asserts that the data is one of the primitive types.

§

Enum(HashSet<String>)

The enum form.

This schema asserts that the data is a string, and that it is one of a set of values.

§

Elements(Schema)

The elements form.

This schema asserts that the instance is an array, and that every element of the array matches a given schema.

§

Properties

The properties form.

This schema asserts that the instance is an object, and that the properties all satisfy their respective schemas.

required is the set of required properties and their schemas. optional is the set of optional properties and their schemas. allow_additional indicates whether it’s acceptable for the instance to have properties other than those mentioned in required and optional.

has_required indicates whether properties exists on the schema. This allows implementations to distinguish the case of an empty properties field from an omitted one. This is necessary for tooling which wants to link to a particular part of a schema in JSON form.

Fields

§required: HashMap<String, Schema>
§optional: HashMap<String, Schema>
§allow_additional: bool
§has_required: bool
§

Values(Schema)

The values form.

This schema asserts that the instance is an object, and that all the values in the object all satisfy the same schema.

§

Discriminator(String, HashMap<String, Schema>)

The discriminator form.

This schema asserts that the instance is an object, and that it has a “tag” property. The value of that tag must be one of the expected “mapping” keys, and the corresponding mapping value is a schema that the instance is expected to satisfy.

The first parameter is the name of the tag property. The second parameter is the mapping from tag values to their corresponding schemas.

Trait Implementations§

Source§

impl Clone for Form

Source§

fn clone(&self) -> Form

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Form

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Form

Source§

fn eq(&self, other: &Form) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Form

Auto Trait Implementations§

§

impl Freeze for Form

§

impl RefUnwindSafe for Form

§

impl Send for Form

§

impl Sync for Form

§

impl Unpin for Form

§

impl UnwindSafe for Form

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.