Struct Response

Source
pub struct Response<'a, T: Clone> {
    pub jsonrpc: Option<TwoPointZero>,
    pub payload: ResponsePayload<'a, T>,
    pub id: Id<'a>,
    pub extensions: Extensions,
}
Expand description

JSON-RPC response object as defined in the spec.

Fields§

§jsonrpc: Option<TwoPointZero>

JSON-RPC version.

§payload: ResponsePayload<'a, T>

Payload which can be result or error.

§id: Id<'a>

Request ID

§extensions: Extensions

Extensions

Implementations§

Source§

impl<'a, T: Clone> Response<'a, T>

Source

pub fn new(payload: ResponsePayload<'a, T>, id: Id<'a>) -> Response<'a, T>

Create a new Response.

Source

pub fn new_with_extensions( payload: ResponsePayload<'a, T>, id: Id<'a>, ext: Extensions, ) -> Response<'a, T>

Create a new Response with extensions

Source

pub fn into_owned(self) -> Response<'static, T>

Create an owned Response.

Source

pub fn extensions(&self) -> &Extensions

Get the extensions of the response.

Source

pub fn extensions_mut(&mut self) -> &mut Extensions

Get the mutable ref to the extensions of the response.

Trait Implementations§

Source§

impl<T> Debug for Response<'_, T>
where T: Serialize + Clone,

Source§

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

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

impl<'de, T> Deserialize<'de> for Response<'de, T>
where T: Deserialize<'de> + Clone,

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>, T: Deserialize<'de> + Clone,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for Response<'_, T>
where T: Serialize + Clone,

Source§

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

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

impl<T> Serialize for Response<'_, T>
where T: Serialize + Clone,

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

impl<'a, T: Clone> TryFrom<Response<'a, T>> for Success<'a, T>

Source§

type Error = ErrorObject<'static>

The type returned in the event of a conversion error.
Source§

fn try_from(rp: Response<'a, T>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a, T> Freeze for Response<'a, T>
where T: Freeze,

§

impl<'a, T> !RefUnwindSafe for Response<'a, T>

§

impl<'a, T> Send for Response<'a, T>
where T: Send + Sync,

§

impl<'a, T> Sync for Response<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for Response<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Response<'a, T>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToString for T
where T: Display + ?Sized,

Source§

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

Source§

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

Source§

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.