pub enum FromSerdeSchemaError {
InvalidForm,
InvalidType(String),
DuplicatedEnumValue(String),
}Expand description
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§
Source§impl Clone for FromSerdeSchemaError
impl Clone for FromSerdeSchemaError
Source§fn clone(&self) -> FromSerdeSchemaError
fn clone(&self) -> FromSerdeSchemaError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FromSerdeSchemaError
impl Debug for FromSerdeSchemaError
Source§impl Display for FromSerdeSchemaError
impl Display for FromSerdeSchemaError
Source§impl Error for FromSerdeSchemaError
impl Error for FromSerdeSchemaError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl PartialEq for FromSerdeSchemaError
impl PartialEq for FromSerdeSchemaError
impl Eq for FromSerdeSchemaError
impl StructuralPartialEq for FromSerdeSchemaError
Auto Trait Implementations§
impl Freeze for FromSerdeSchemaError
impl RefUnwindSafe for FromSerdeSchemaError
impl Send for FromSerdeSchemaError
impl Sync for FromSerdeSchemaError
impl Unpin for FromSerdeSchemaError
impl UnwindSafe for FromSerdeSchemaError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more