pub struct Response { /* private fields */ }
Expand description
A successful or failed JSON-RPC response.
Implementations§
source§impl Response
impl Response
sourcepub const fn from_ok(id: Id, result: Value) -> Self
pub const fn from_ok(id: Id, result: Value) -> Self
Creates a new successful response from a request ID and Error
object.
sourcepub const fn from_error(id: Id, error: Error) -> Self
pub const fn from_error(id: Id, error: Error) -> Self
Creates a new error response from a request ID and Error
object.
sourcepub fn from_parts(id: Id, body: Result<Value>) -> Self
pub fn from_parts(id: Id, body: Result<Value>) -> Self
Creates a new response from a request ID and either an Ok(Value)
or Err(Error)
body.
sourcepub fn into_parts(self) -> (Id, Result<Value>)
pub fn into_parts(self) -> (Id, Result<Value>)
Splits the response into a request ID paired with either an Ok(Value)
or Err(Error)
to
signify whether the response is a success or failure.
sourcepub const fn result(&self) -> Option<&Value>
pub const fn result(&self) -> Option<&Value>
Returns the result
value, if it exists.
This member only exists if the response indicates success.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Response
impl<'de> Deserialize<'de> for Response
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 PartialEq<Response> for Response
impl PartialEq<Response> for Response
source§impl Sink<Response> for ClientSocket
impl Sink<Response> for ClientSocket
Routes client-to-server responses back to the server.
§type Error = ExitedError
type Error = ExitedError
The type of value produced by the sink when an error occurs.
source§fn poll_ready(
self: Pin<&mut Self>,
_: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
fn poll_ready( self: Pin<&mut Self>, _: &mut Context<'_> ) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink
to receive a value. Read moresource§fn start_send(self: Pin<&mut Self>, item: Response) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: Response) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read more