Struct jsonrpsee_core::server::helpers::MethodResponse
source · pub struct MethodResponse {
pub result: String,
pub success_or_error: MethodResponseResult,
pub is_subscription: bool,
}server only.Expand description
Represents a response to a method call.
NOTE: A subscription is also a method call but it’s
possible determine whether a method response
is “subscription” or “ordinary method call”
by calling MethodResponse::is_subscription
Fields§
§result: StringSerialized JSON-RPC response,
success_or_error: MethodResponseResultIndicates whether the call was successful or not.
is_subscription: boolIndicates whether the call was a subscription response.
Implementations§
source§impl MethodResponse
impl MethodResponse
sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns whether the call was successful.
sourcepub fn is_subscription(&self) -> bool
pub fn is_subscription(&self) -> bool
Returns whether the call is a subscription.
source§impl MethodResponse
impl MethodResponse
sourcepub fn subscription_response<T>(
id: Id<'_>,
result: ResponsePayload<'_, T>,
max_response_size: usize
) -> Self
pub fn subscription_response<T>( id: Id<'_>, result: ResponsePayload<'_, T>, max_response_size: usize ) -> Self
This is similar to MethodResponse::response but sets a flag to indicate
that response is a subscription.
sourcepub fn response<T>(
id: Id<'_>,
result: ResponsePayload<'_, T>,
max_response_size: usize
) -> Self
pub fn response<T>( id: Id<'_>, result: ResponsePayload<'_, T>, max_response_size: usize ) -> Self
Create a new method response.
If the serialization of result exceeds max_response_size then
the response is changed to an JSON-RPC error object.
sourcepub fn subscription_error<'a>(
id: Id<'_>,
err: impl Into<ErrorObject<'a>>
) -> Self
pub fn subscription_error<'a>( id: Id<'_>, err: impl Into<ErrorObject<'a>> ) -> Self
This is similar to MethodResponse::error but sets a flag to indicate
that error is a subscription.
sourcepub fn error<'a>(id: Id<'_>, err: impl Into<ErrorObject<'a>>) -> Self
pub fn error<'a>(id: Id<'_>, err: impl Into<ErrorObject<'a>>) -> Self
Create a MethodResponse from a JSON-RPC error.
Trait Implementations§
source§impl Clone for MethodResponse
impl Clone for MethodResponse
source§fn clone(&self) -> MethodResponse
fn clone(&self) -> MethodResponse
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more