pub struct Response { /* private fields */ }
Expand description
A successful or failed JSON-RPC response.
Implementations
sourceimpl 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
sourceimpl<'de> Deserialize<'de> for Response
impl<'de> Deserialize<'de> for Response
sourcefn 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
sourceimpl 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.
sourcefn 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 moresourcefn 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 moreimpl StructuralPartialEq for Response
Auto Trait Implementations
impl RefUnwindSafe for Response
impl Send for Response
impl Sync for Response
impl Unpin for Response
impl UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more