Skip to main content

SerdeError

Enum SerdeError 

Source
#[non_exhaustive]
pub enum SerdeError {
#[non_exhaustive]
TypeMismatch { message: String, },
#[non_exhaustive]
MissingMember { member_name: String, },
#[non_exhaustive]
UnknownMember { member_name: String, },
#[non_exhaustive]
InvalidInput { message: String, },
#[non_exhaustive]
UnsupportedOperation { message: String, },
#[non_exhaustive]
WriteFailed { message: String, },
#[non_exhaustive]
NumericCoercionOverflow { target: String, value: String, },
#[non_exhaustive]
NumericCoercionLossy { target: String, value: String, },
#[non_exhaustive]
BlobDecodeFailed { message: String, },
#[non_exhaustive]
TimestampParseFailed { message: String, },
#[non_exhaustive]
Custom { message: String, }, }
Expand description

Error type for shape serialization and deserialization operations.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

#[non_exhaustive]
TypeMismatch

The data did not match the expected type described by the schema.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Description of what was expected vs what was found.

§

#[non_exhaustive]
MissingMember

A required structure member was missing during deserialization.

Not currently emitted. The schema-serde deserializers use the push/consumer pattern and defer required-member enforcement to the generated builder’s build(). This variant is reserved for deserializers that choose to enforce member presence during the read.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§member_name: String

The name of the missing member.

§

#[non_exhaustive]
UnknownMember

An unknown member was encountered during deserialization.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§member_name: String

The name of the unknown member.

§

#[non_exhaustive]
InvalidInput

The input data was malformed or invalid for the format.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Description of the problem.

§

#[non_exhaustive]
UnsupportedOperation

The operation is not supported by this serializer or deserializer.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Description of what was attempted.

§

#[non_exhaustive]
WriteFailed

An error occurred while writing output during serialization.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Description of the write failure.

§

#[non_exhaustive]
NumericCoercionOverflow

A numeric coercion overflowed the target type’s representable range.

Emitted by the narrow numeric reads on ShapeDeserializer (read_byte, read_short, read_integer, read_long) when the source value is outside the target’s [min, max] range.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§target: String

Target type name (e.g. "byte", "integer", "long").

§value: String

String representation of the overflowing value, included for diagnostics.

§

#[non_exhaustive]
NumericCoercionLossy

A numeric coercion would lose precision in a context where precision loss is not acceptable.

Not currently emitted by the standard numeric reads. Per the SEP “Number coercion” rules, precision loss is silently ignored on the standard coercion path. This variant is reserved for callers (e.g. strict deserializers, customer code using a custom accessor) that choose to enforce lossless coercion.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§target: String

Target type name.

§value: String

String representation of the value that would lose precision.

§

#[non_exhaustive]
BlobDecodeFailed

Failed to decode a blob from its wire-format representation — for example, invalid base64 in a JSON payload.

Not currently emitted. In-tree codecs surface blob-decode failures as InvalidInput. This variant is reserved for codecs that want to distinguish blob-decode failures as a separate category.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Description of the decode failure.

§

#[non_exhaustive]
TimestampParseFailed

Failed to parse a timestamp from its wire-format representation — for example, a malformed RFC-3339 string or an out-of-range epoch-seconds value.

Not currently emitted. In-tree codecs surface timestamp-parse failures as InvalidInput. This variant is reserved for codecs that want to distinguish timestamp-parse failures as a separate category.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Description of the parse failure.

§

#[non_exhaustive]
Custom

Catch-all for errors not covered by other variants.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: String

Explanatory message.

Implementations§

Source§

impl SerdeError

Source

pub fn type_mismatch(message: impl Into<String>) -> Self

Creates a TypeMismatch error describing what was expected versus what was found.

Source

pub fn missing_member(member_name: impl Into<String>) -> Self

Creates a MissingMember error for the given member name.

Source

pub fn unknown_member(member_name: impl Into<String>) -> Self

Creates an UnknownMember error for the given member name.

Source

pub fn invalid_input(message: impl Into<String>) -> Self

Creates an InvalidInput error with the given message.

Source

pub fn unsupported(message: impl Into<String>) -> Self

Creates an UnsupportedOperation error with the given message.

Source

pub fn write_failed(message: impl Into<String>) -> Self

Creates a WriteFailed error with the given message.

Source

pub fn numeric_coercion_overflow( target: impl Into<String>, value: impl Into<String>, ) -> Self

Creates a NumericCoercionOverflow error for a value that is outside the representable range of target (e.g. "byte").

Source

pub fn numeric_coercion_lossy( target: impl Into<String>, value: impl Into<String>, ) -> Self

Creates a NumericCoercionLossy error for a value that cannot be coerced to target without losing precision.

Source

pub fn blob_decode_failed(message: impl Into<String>) -> Self

Creates a BlobDecodeFailed error with the given message.

Source

pub fn timestamp_parse_failed(message: impl Into<String>) -> Self

Creates a TimestampParseFailed error with the given message.

Source

pub fn custom(message: impl Into<String>) -> Self

Creates a custom error with the given message.

Trait Implementations§

Source§

impl Debug for SerdeError

Source§

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

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

impl Display for SerdeError

Source§

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

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

impl Error for SerdeError

1.30.0 · Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<DocumentError> for SerdeError

Lift a DocumentError coming out of the format-aware coercion accessors on DiscriminatedDocument and the DocumentSettings hooks they dispatch through, into the schema crate’s broader SerdeError.

The variant shapes line up one-to-one — DocumentError is a strict subset (Document-shaped failures only); SerdeError adds shape-serde concerns like missing/unknown members and write failures that are out of scope for the types crate.

Source§

fn from(err: DocumentError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more