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>

source

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>
where Data: Borrow<RawValue> + 'a,

source

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 no data field.
  • Some(Ok(data)) if the error has a data field that can be deserialized.
  • Some(Err(err)) if the error has a data field that can’t be deserialized.
source

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 deserialized
  • Err(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>

source§

fn clone(&self) -> ErrorPayload<ErrData>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<ErrData: Debug> Debug for ErrorPayload<ErrData>

source§

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

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

impl<'de, ErrData: Deserialize<'de>> Deserialize<'de> for ErrorPayload<ErrData>

source§

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>

source§

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

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

impl<ErrData> Serialize for ErrorPayload<ErrData>
where ErrData: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> 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> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

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

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

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

source§

default 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>,

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> RpcObject for T
where T: RpcParam + RpcReturn,

source§

impl<T> RpcParam for T
where T: Serialize + Clone + Debug + Send + Sync + Unpin,

source§

impl<T> RpcReturn for T
where T: DeserializeOwned + Debug + Send + Sync + Unpin + 'static,