Struct alloy_json_rpc::ErrorPayload
source · pub struct ErrorPayload<ErrData = Box<RawValue>> {
pub code: i64,
pub message: String,
pub data: Option<ErrData>,
}
Expand description
A JSONRPC-2.0 error object.
This response indicates that the server received and handled the request,
but that there was an error in the processing of it. The error should be
included in the message
field of the response payload.
Fields§
§code: i64
The error code.
message: String
The error message (if any).
data: Option<ErrData>
The error data (if any).
Implementations§
source§impl ErrorPayload<&RawValue>
impl ErrorPayload<&RawValue>
sourcepub fn into_owned(self) -> ErrorPayload
pub fn into_owned(self) -> ErrorPayload
Convert this borrowed error payload into an owned payload by copying the data from the deserializer (if necessary).
source§impl<'a, Data> ErrorPayload<Data>
impl<'a, Data> ErrorPayload<Data>
sourcepub fn try_data_as<T: Deserialize<'a>>(&'a self) -> Option<Result<T>>
pub fn try_data_as<T: Deserialize<'a>>(&'a self) -> Option<Result<T>>
Deserialize the error’s data
field, borrowing from the data field if
necessary.
§Returns
None
if the error has nodata
field.Some(Ok(data))
if the error has adata
field that can be deserialized.Some(Err(err))
if the error has adata
field that can’t be deserialized.
sourcepub fn deser_data<T: DeserializeOwned>(self) -> Result<ErrorPayload<T>, Self>
pub fn deser_data<T: DeserializeOwned>(self) -> Result<ErrorPayload<T>, Self>
Attempt to deserialize the data field.
§Returns
Ok(ErrorPayload<T>)
if the data field can be deserializedErr(self)
if the data field can’t be deserialized, or if there is no data field.
Trait Implementations§
source§impl<ErrData: Clone> Clone for ErrorPayload<ErrData>
impl<ErrData: Clone> Clone for ErrorPayload<ErrData>
source§fn clone(&self) -> ErrorPayload<ErrData>
fn clone(&self) -> ErrorPayload<ErrData>
Returns a copy 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<ErrData: Debug> Debug for ErrorPayload<ErrData>
impl<ErrData: Debug> Debug for ErrorPayload<ErrData>
source§impl<'de, ErrData: Deserialize<'de>> Deserialize<'de> for ErrorPayload<ErrData>
impl<'de, ErrData: Deserialize<'de>> Deserialize<'de> for ErrorPayload<ErrData>
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<ErrData> Display for ErrorPayload<ErrData>
impl<ErrData> Display for ErrorPayload<ErrData>
Auto Trait Implementations§
impl<ErrData> Freeze for ErrorPayload<ErrData>where
ErrData: Freeze,
impl<ErrData> RefUnwindSafe for ErrorPayload<ErrData>where
ErrData: RefUnwindSafe,
impl<ErrData> Send for ErrorPayload<ErrData>where
ErrData: Send,
impl<ErrData> Sync for ErrorPayload<ErrData>where
ErrData: Sync,
impl<ErrData> Unpin for ErrorPayload<ErrData>where
ErrData: Unpin,
impl<ErrData> UnwindSafe for ErrorPayload<ErrData>where
ErrData: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)