[][src]Enum schemars::schema::Schema

pub enum Schema {
    Bool(bool),
    Object(SchemaObject),
}

A JSON Schema.

Variants

Bool(bool)

A trivial boolean JSON Schema.

The schema true matches everything (always passes validation), whereas the schema false matches nothing (always fails validation).

Object(SchemaObject)

A JSON Schema object.

Implementations

impl Schema[src]

pub fn new_ref(reference: String) -> Self[src]

Creates a new $ref schema.

The given reference string should be a URI reference. This will usually be a JSON Pointer in URI Fragment representation.

pub fn is_ref(&self) -> bool[src]

Returns true if self is a $ref schema.

If self is a SchemaObject with Some reference set, this returns true. Otherwise, returns false.

pub fn into_object(self) -> SchemaObject[src]

Converts the given schema (if it is a boolean schema) into an equivalent schema object.

If the given schema is already a schema object, this has no effect.

Example

use schemars::schema::{Schema, SchemaObject};

let bool_schema = Schema::Bool(true);

assert_eq!(bool_schema.into_object(), SchemaObject::default());

Trait Implementations

impl Clone for Schema[src]

impl Debug for Schema[src]

impl<'de> Deserialize<'de> for Schema[src]

impl From<Schema> for SchemaObject[src]

impl From<SchemaObject> for Schema[src]

impl From<bool> for Schema[src]

impl JsonSchema for Schema[src]

impl PartialEq<Schema> for Schema[src]

impl Serialize for Schema[src]

impl StructuralPartialEq for Schema[src]

Auto Trait Implementations

impl RefUnwindSafe for Schema

impl Send for Schema

impl Sync for Schema

impl Unpin for Schema

impl UnwindSafe for Schema

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.