Struct alloy_json_rpc::Response
source · pub struct Response<Payload = Box<RawValue>, ErrData = Box<RawValue>> {
pub id: Id,
pub payload: ResponsePayload<Payload, ErrData>,
}
Expand description
A JSONRPC-2.0 response object containing a ResponsePayload
.
This object is used to represent a JSONRPC-2.0 response. It may contain
either a successful result or an error. The id
field is used to match
the response to the request that it is responding to, and should be
mirrored from the response.
Fields§
§id: Id
The ID of the request that this response is responding to.
payload: ResponsePayload<Payload, ErrData>
The response payload.
Implementations§
source§impl Response<&RawValue, &RawValue>
impl Response<&RawValue, &RawValue>
sourcepub fn into_owned(self) -> Response
pub fn into_owned(self) -> Response
Convert this borrowed response to an owned response by copying the data from the deserializer (if necessary).
source§impl<'a, Payload, ErrData> Response<Payload, ErrData>
impl<'a, Payload, ErrData> Response<Payload, ErrData>
sourcepub fn try_success_as<T: Deserialize<'a>>(&'a self) -> Option<Result<T>>
pub fn try_success_as<T: Deserialize<'a>>(&'a self) -> Option<Result<T>>
Attempt to deserialize the success payload, borrowing from the payload if necessary.
sourcepub fn deser_success<T: DeserializeOwned>(
self,
) -> Result<Response<T, ErrData>, Self>
pub fn deser_success<T: DeserializeOwned>( self, ) -> Result<Response<T, ErrData>, Self>
Attempt to deserialize the Success payload, transforming this type.
§Returns
Ok(Response<T, ErrData>)
if the payload is a success and can be deserialized as T, or if the payload is an error.Err(self)
if the payload is a success and can’t be deserialized.
source§impl<'a, Payload, ErrData> Response<Payload, ErrData>
impl<'a, Payload, ErrData> Response<Payload, ErrData>
sourcepub fn try_error_as<T: Deserialize<'a>>(&'a self) -> Option<Result<T>>
pub fn try_error_as<T: Deserialize<'a>>(&'a self) -> Option<Result<T>>
Attempt to deserialize the error payload, borrowing from the payload if necessary.
sourcepub fn deser_err<T: DeserializeOwned>(
self,
) -> Result<Response<Payload, T>, Self>
pub fn deser_err<T: DeserializeOwned>( self, ) -> Result<Response<Payload, T>, Self>
Attempt to deserialize the Error payload, transforming this type.
§Returns
Ok(Response<Payload, T>)
if the payload is an error and can be deserialized asT
, or if the payload is a success.Err(self)
if the payload is an error and can’t be deserialized.
Trait Implementations§
source§impl<'de, Payload, ErrData> Deserialize<'de> for Response<Payload, ErrData>where
Payload: Deserialize<'de>,
ErrData: Deserialize<'de>,
impl<'de, Payload, ErrData> Deserialize<'de> for Response<Payload, ErrData>where
Payload: Deserialize<'de>,
ErrData: Deserialize<'de>,
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>,
source§impl From<Response> for PubSubItem
impl From<Response> for PubSubItem
source§impl<Payload, ErrData> FromIterator<Response<Payload, ErrData>> for ResponsePacket<Payload, ErrData>
impl<Payload, ErrData> FromIterator<Response<Payload, ErrData>> for ResponsePacket<Payload, ErrData>
Auto Trait Implementations§
impl<Payload, ErrData> Freeze for Response<Payload, ErrData>
impl<Payload, ErrData> RefUnwindSafe for Response<Payload, ErrData>where
Payload: RefUnwindSafe,
ErrData: RefUnwindSafe,
impl<Payload, ErrData> Send for Response<Payload, ErrData>
impl<Payload, ErrData> Sync for Response<Payload, ErrData>
impl<Payload, ErrData> Unpin for Response<Payload, ErrData>
impl<Payload, ErrData> UnwindSafe for Response<Payload, ErrData>where
Payload: UnwindSafe,
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
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)
clone_to_uninit
)