Enum jtd::FromSerdeSchemaError[][src]

pub enum FromSerdeSchemaError {
    InvalidForm,
    InvalidType(String),
    DuplicatedEnumValue(String),
}

Errors that may arise from Schema::from_serde_schema.

Variants

InvalidForm

Indicates the schema uses an invalid combination of keywords.

use jtd::{FromSerdeSchemaError, Schema, SerdeSchema};

assert_eq!(
    Err(FromSerdeSchemaError::InvalidForm),

    // it's invalid to have both "type" and "enum" on a schema
    Schema::from_serde_schema(SerdeSchema {
        type_: Some("uint8".to_owned()),
        enum_: Some(Default::default()),
        ..Default::default()
    })
)
InvalidType(String)

Indicates the schema uses a value for type that isn't in Type.

use jtd::{FromSerdeSchemaError, Schema, SerdeSchema};

assert_eq!(
    Err(FromSerdeSchemaError::InvalidType("uint64".to_owned())),

    // there is no uint64 in JSON Typedef
    Schema::from_serde_schema(SerdeSchema {
        type_: Some("uint64".to_owned()),
        ..Default::default()
    })
)
DuplicatedEnumValue(String)

Indicates the schema has the same value appearing twice in an enum.

use jtd::{FromSerdeSchemaError, Schema, SerdeSchema};

assert_eq!(
    Err(FromSerdeSchemaError::DuplicatedEnumValue("foo".to_owned())),

    // it's invalid to have the same value appear twice in an enum array
    Schema::from_serde_schema(SerdeSchema {
        enum_: Some(vec!["foo".into(), "bar".into(), "foo".into()]),
        ..Default::default()
    })
)

Trait Implementations

impl Clone for FromSerdeSchemaError[src]

impl Debug for FromSerdeSchemaError[src]

impl Display for FromSerdeSchemaError[src]

impl Eq for FromSerdeSchemaError[src]

impl Error for FromSerdeSchemaError[src]

impl PartialEq<FromSerdeSchemaError> for FromSerdeSchemaError[src]

impl StructuralEq for FromSerdeSchemaError[src]

impl StructuralPartialEq for FromSerdeSchemaError[src]

Auto Trait Implementations

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> 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> ToString for T where
    T: Display + ?Sized
[src]

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.