#[non_exhaustive]pub enum AnyError {
Serialization(Box<dyn Error + Send + Sync>),
Deserialization(Box<dyn Error + Send + Sync>),
TypeMismatch {
has: String,
want: String,
},
}Expand description
Indicates a problem trying to use an Any.
§Example
use serde_json::json;
let any = serde_json::from_value::<Any>(json!({
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "123.5" // missing `s` suffix
}))?;
let extracted = any.to_msg::<Duration>();
assert!(matches!(extracted, Err(AnyError::Deserialization(_))));§Example
let duration = Duration::clamp(60, 0);
let any = Any::from_msg(&duration)?;
let extracted = any.to_msg::<Timestamp>();
assert!(matches!(extracted, Err(AnyError::TypeMismatch{..})));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.
Serialization(Box<dyn Error + Send + Sync>)
Problem serializing an object into an Any.
Deserialization(Box<dyn Error + Send + Sync>)
Problem deserializing an object from an Any.
TypeMismatch
Mismatched type, the Any does not contain the desired type.
Trait Implementations§
Source§impl Error for AnyError
impl Error for AnyError
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()
Auto Trait Implementations§
impl Freeze for AnyError
impl !RefUnwindSafe for AnyError
impl Send for AnyError
impl Sync for AnyError
impl Unpin for AnyError
impl UnsafeUnpin for AnyError
impl !UnwindSafe for AnyError
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