pub enum RawResponse<'a> {
Ok(OkResponse<'a>),
Error(ErrorResponse<'a>),
}
Expand description
A JSON-RPC response is either a “result” or “error” payload. This represents the shape a message can deserialize into.
Variants§
Ok(OkResponse<'a>)
A JSON-RPC “result” response.
Error(ErrorResponse<'a>)
A JSON-RPC “error” response.
Implementations§
Source§impl<'a> RawResponse<'a>
impl<'a> RawResponse<'a>
Sourcepub fn id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
Return the ID associated with the response, if there is one. Notifications from the server that aren’t associated with a request won’t.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<RawResponse<'_>, ResponseError>
pub fn from_bytes(bytes: &[u8]) -> Result<RawResponse<'_>, ResponseError>
Decode some bytes into a valid JSON-RPC response or return an error if it’s not valid.
Sourcepub fn into_owned(self) -> RawResponse<'static>
pub fn into_owned(self) -> RawResponse<'static>
Take ownership of a [Response
], removing any lifetimes.
Sourcepub fn ok_from_value<V: Serialize, Id: ToString>(
id: Option<Id>,
value: V,
) -> RawResponse<'static>
pub fn ok_from_value<V: Serialize, Id: ToString>( id: Option<Id>, value: V, ) -> RawResponse<'static>
Construct an “ok” response from an optional ID and serializable “result” value. Panics if the value given does not serialize to valid JSON.
Sourcepub fn err_from_value<Id: ToString>(
id: Option<Id>,
error: ErrorObject<'_>,
) -> RawResponse<'static>
pub fn err_from_value<Id: ToString>( id: Option<Id>, error: ErrorObject<'_>, ) -> RawResponse<'static>
Construct an “error” response from an optional ID and error object.
Trait Implementations§
Source§impl<'a> Clone for RawResponse<'a>
impl<'a> Clone for RawResponse<'a>
Source§fn clone(&self) -> RawResponse<'a>
fn clone(&self) -> RawResponse<'a>
Returns a duplicate 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<'a> Debug for RawResponse<'a>
impl<'a> Debug for RawResponse<'a>
Auto Trait Implementations§
impl<'a> Freeze for RawResponse<'a>
impl<'a> RefUnwindSafe for RawResponse<'a>
impl<'a> Send for RawResponse<'a>
impl<'a> Sync for RawResponse<'a>
impl<'a> Unpin for RawResponse<'a>
impl<'a> UnwindSafe for RawResponse<'a>
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