Enum ResponsePayload
pub enum ResponsePayload<'a, T>where
T: Clone,{
Success(Cow<'a, T>),
Error(ErrorObject<'a>),
}Available on crate feature
server-core only.Expand description
Represent the payload of the JSON-RPC response object
It can be:
"result":<value>
"error":{"code":<code>,"message":<msg>,"data":<data>}Variants§
Success(Cow<'a, T>)
Corresponds to successful JSON-RPC response with the field result.
Error(ErrorObject<'a>)
Corresponds to failed JSON-RPC response with a error object with the field `error.
Implementations§
§impl<'a, T> ResponsePayload<'a, T>where
T: Clone,
impl<'a, T> ResponsePayload<'a, T>where
T: Clone,
pub fn success(t: T) -> ResponsePayload<'a, T>
pub fn success(t: T) -> ResponsePayload<'a, T>
Create a successful owned response payload.
pub fn success_borrowed(t: &'a T) -> ResponsePayload<'a, T>
pub fn success_borrowed(t: &'a T) -> ResponsePayload<'a, T>
Create a successful borrowed response payload.
pub fn into_owned(self) -> ResponsePayload<'static, T>
pub fn into_owned(self) -> ResponsePayload<'static, T>
Convert the response payload into owned.
pub fn error(e: impl Into<ErrorObject<'static>>) -> ResponsePayload<'a, T>
pub fn error(e: impl Into<ErrorObject<'static>>) -> ResponsePayload<'a, T>
Create an error response payload.
pub fn error_borrowed(e: impl Into<ErrorObject<'a>>) -> ResponsePayload<'a, T>
pub fn error_borrowed(e: impl Into<ErrorObject<'a>>) -> ResponsePayload<'a, T>
Create a borrowed error response payload.
Trait Implementations§
§impl<'a, T> Clone for ResponsePayload<'a, T>where
T: Clone,
impl<'a, T> Clone for ResponsePayload<'a, T>where
T: Clone,
§fn clone(&self) -> ResponsePayload<'a, T>
fn clone(&self) -> ResponsePayload<'a, T>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl<'a, T> Debug for ResponsePayload<'a, T>
impl<'a, T> Debug for ResponsePayload<'a, T>
§impl<'a, T> From<ErrorCode> for ResponsePayload<'a, T>where
T: Clone,
impl<'a, T> From<ErrorCode> for ResponsePayload<'a, T>where
T: Clone,
§fn from(code: ErrorCode) -> ResponsePayload<'a, T>
fn from(code: ErrorCode) -> ResponsePayload<'a, T>
Converts to this type from the input type.
§impl<T> IntoResponse for ResponsePayload<'static, T>
impl<T> IntoResponse for ResponsePayload<'static, T>
§fn into_response(
self,
) -> ResponsePayload<'static, <ResponsePayload<'static, T> as IntoResponse>::Output>
fn into_response( self, ) -> ResponsePayload<'static, <ResponsePayload<'static, T> as IntoResponse>::Output>
Something that can be converted into a JSON-RPC method call response.
§impl<'a, T> PartialEq for ResponsePayload<'a, T>
impl<'a, T> PartialEq for ResponsePayload<'a, T>
impl<'a, T> StructuralPartialEq for ResponsePayload<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for ResponsePayload<'a, T>
impl<'a, T> RefUnwindSafe for ResponsePayload<'a, T>where
Cow<'a, T>: RefUnwindSafe,
impl<'a, T> Send for ResponsePayload<'a, T>
impl<'a, T> Sync for ResponsePayload<'a, T>
impl<'a, T> Unpin for ResponsePayload<'a, T>
impl<'a, T> UnsafeUnpin for ResponsePayload<'a, T>where
Cow<'a, T>: UnsafeUnpin,
impl<'a, T> UnwindSafe for ResponsePayload<'a, T>where
Cow<'a, T>: 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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘwhere
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.