#[non_exhaustive]pub enum DocumentError {
#[non_exhaustive] TypeMismatch {
message: String,
},
#[non_exhaustive] NumericCoercionOverflow {
target: String,
value: String,
},
#[non_exhaustive] InvalidInput {
message: String,
},
#[non_exhaustive] Custom {
message: String,
},
#[non_exhaustive] UnsupportedOperation {
message: String,
},
}Expand description
Error returned by Document-shaped coercion
operations.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
#[non_exhaustive]TypeMismatch
The document’s variant didn’t match the type the caller asked for, and no coercion is defined between the actual and the requested type.
Example: calling
DiscriminatedDocument::as_blob
on a Document::Number(_).
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]NumericCoercionOverflow
A numeric coercion overflowed the target type’s representable range.
Emitted when a source value is outside the target’s
[min, max] range.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]InvalidInput
The document’s value couldn’t be parsed into the requested
representation. Distinct from TypeMismatch: the variants
match, but the underlying string is malformed.
Example: a Document::String whose
text isn’t valid base64 when coercing to a blob.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]Custom
Catch-all for errors not covered by other variants.
Fields
This variant is marked as non-exhaustive
#[non_exhaustive]UnsupportedOperation
The operation is not supported on this document. Used by
DiscriminatedDocument’s
format-aware coercion accessors, and by
DocumentSettings trait default
methods for a coercion a particular protocol doesn’t support.
Fields
This variant is marked as non-exhaustive
Implementations§
Source§impl DocumentError
impl DocumentError
Sourcepub fn type_mismatch(message: impl Into<String>) -> Self
pub fn type_mismatch(message: impl Into<String>) -> Self
Creates a TypeMismatch error with the given message describing
what was expected versus what was found.
Sourcepub fn numeric_coercion_overflow(
target: impl Into<String>,
value: impl Into<String>,
) -> Self
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").
Sourcepub fn invalid_input(message: impl Into<String>) -> Self
pub fn invalid_input(message: impl Into<String>) -> Self
Creates an InvalidInput error with the given message.
Sourcepub fn custom(message: impl Into<String>) -> Self
pub fn custom(message: impl Into<String>) -> Self
Creates a custom error with the given message.
Sourcepub fn unsupported(message: impl Into<String>) -> Self
pub fn unsupported(message: impl Into<String>) -> Self
Creates an UnsupportedOperation error with the given message.
Trait Implementations§
Source§impl Debug for DocumentError
impl Debug for DocumentError
Source§impl Display for DocumentError
impl Display for DocumentError
Source§impl Error for DocumentError
impl Error for DocumentError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for DocumentError
impl RefUnwindSafe for DocumentError
impl Send for DocumentError
impl Sync for DocumentError
impl Unpin for DocumentError
impl UnsafeUnpin for DocumentError
impl UnwindSafe for DocumentError
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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