pub enum Schema {
    Null(NullContext),
    Boolean(BooleanContext),
    Integer(NumberContext<i128>),
    Float(NumberContext<f64>),
    String(StringContext),
    Bytes(BytesContext),
    Sequence {
        field: Box<Field>,
        context: SequenceContext,
    },
    Struct {
        fields: BTreeMap<String, Field>,
        context: MapStructContext,
    },
    Union {
        variants: Vec<Schema>,
    },
}
Expand description

This enum is the core output of the analysis, it describes the structure of a document.

Each variant also contains context data that allows it to store information about the values it has encountered.

Variants§

§

Null(NullContext)

The Null variant is a special one that is only ever found when a document has a single null value at the root of the document. Null values in Structs or Sequences are instead handled at the Field level, where it is more ergonomic.

§

Boolean(BooleanContext)

Represents a boolean value.

§

Integer(NumberContext<i128>)

Represents an integer value.

§

Float(NumberContext<f64>)

Represents a floating point value.

§

String(StringContext)

Represents a textual value.

§

Bytes(BytesContext)

Represents a value of raw bytes.

§

Sequence

Fields

§field: Box<Field>

The field is the structure shared by all the elements of the sequence.

§context: SequenceContext

The context aggregates information about the sequence. It is passed the length of the sequence.

Represents a sequence of values described by a Field. It assumes all values share the same schema.

§

Struct

Fields

§fields: BTreeMap<String, Field>

Each String key gets assigned a Field. Currently we are using a BTreeMap, but that might change in the future.

§context: MapStructContext

The context aggregates information about the struct. It is passed a vector of the key names.

Represents a String->Field mapping.

Note: currently there is not a true map and only strings may be used as keys.

§

Union

Fields

§variants: Vec<Schema>

A list of the possible schemas that were found.

Simply a vector of Schemas, it should never contain an Union or multiple instances of the same variant inside.

Note: content needs to be a struct variant to work with #[serde(tag = "type")].

Implementations§

Convert a Schema to a json_typegen Shape.

Convert a Schema to a supported json_typegen output

Convert a Schema to a supported json_typegen output using custom settings.

Convert into a json_schema using the default settings.

Convert into a specific version of json_schema.

Convert using a provided generator (which also holds the settings) to a json schema.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Merge other into self.
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts to this type from the input type.
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Serialize this value into the given Serde serializer. Read more
Returns true if self and other share the same structure.
Returns true if self and other DO NOT share the same structure.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Merge other into self. Trait object is returned if merging was unsuccessful.
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.