pub struct JsonRpcMethod<'a, I, O, E> {
pub method: &'a str,
/* private fields */
}Expand description
Defines a json-rpc method and describes the schema of the input I, output O and error-type E.
The error-type can be serialized and deserialized
Fields§
§method: &'a strImplementations§
Source§impl<'a, I, O, E> JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> JsonRpcMethod<'a, I, O, E>
pub const fn new(method: &'a str) -> Self
pub const fn name(&self) -> &'a str
Sourcepub fn create_request(
&self,
params: I,
json_rpc_id: JsonRpcId,
) -> JsonRpcRequest<I>
pub fn create_request( &self, params: I, json_rpc_id: JsonRpcId, ) -> JsonRpcRequest<I>
Creates a JsonRpcRequest with parameters for the given method
pub fn create_ok_response( &self, request: JsonRpcRequest<I>, result: O, ) -> JsonRpcResponse<O, E>
pub fn into_typed_request(
&self,
request: JsonRpcRequest<Value>,
) -> Result<JsonRpcRequest<I>, ErrorData>where
I: DeserializeOwned + ExpectedFields,
Source§impl<O, E> JsonRpcMethod<'_, NoParams, O, E>
impl<O, E> JsonRpcMethod<'_, NoParams, O, E>
pub fn create_request_no_params( &self, json_rpc_id: JsonRpcId, ) -> JsonRpcRequest<NoParams>
Source§impl<'de, I, O, E> JsonRpcMethod<'de, I, O, E>where
O: Deserialize<'de>,
E: Deserialize<'de>,
impl<'de, I, O, E> JsonRpcMethod<'de, I, O, E>where
O: Deserialize<'de>,
E: Deserialize<'de>,
pub fn parse_json_response_str( &self, json_str: &'de str, ) -> Result<JsonRpcResponse<O, E>, Error>
Source§impl<I, O, E> JsonRpcMethod<'_, I, O, E>where
O: DeserializeOwned,
E: DeserializeOwned,
impl<I, O, E> JsonRpcMethod<'_, I, O, E>where
O: DeserializeOwned,
E: DeserializeOwned,
pub fn parse_json_response_value( &self, json_value: Value, ) -> Result<JsonRpcResponse<O, E>, Error>
Source§impl<I, O, E> JsonRpcMethod<'static, I, O, E>where
I: DeserializeOwned + Serialize + 'static,
O: DeserializeOwned + Serialize + 'static,
E: DeserializeOwned + Serialize + 'static,
impl<I, O, E> JsonRpcMethod<'static, I, O, E>where
I: DeserializeOwned + Serialize + 'static,
O: DeserializeOwned + Serialize + 'static,
E: DeserializeOwned + Serialize + 'static,
pub fn erase_box(self) -> Box<dyn JsonRpcMethodErased<'static>>
pub fn ref_erase(&self) -> &dyn JsonRpcMethodErased<'_>
Trait Implementations§
Source§impl<'a, I: Clone, O: Clone, E: Clone> Clone for JsonRpcMethod<'a, I, O, E>
impl<'a, I: Clone, O: Clone, E: Clone> Clone for JsonRpcMethod<'a, I, O, E>
Source§fn clone(&self) -> JsonRpcMethod<'a, I, O, E>
fn clone(&self) -> JsonRpcMethod<'a, I, O, E>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'de: 'a, 'a, I, O, E> Deserialize<'de> for JsonRpcMethod<'a, I, O, E>
impl<'de: 'a, 'a, I, O, E> Deserialize<'de> for JsonRpcMethod<'a, I, O, E>
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<'a, I, O, E> From<&'a JsonRpcMethod<'a, I, O, E>> for String
impl<'a, I, O, E> From<&'a JsonRpcMethod<'a, I, O, E>> for String
Source§fn from(value: &JsonRpcMethod<'_, I, O, E>) -> Self
fn from(value: &JsonRpcMethod<'_, I, O, E>) -> Self
Converts to this type from the input type.
Source§impl<'a, I, O, E> JsonRpcMethodErased<'a> for JsonRpcMethod<'_, I, O, E>where
I: DeserializeOwned + Serialize,
O: DeserializeOwned + Serialize,
E: DeserializeOwned + Serialize,
impl<'a, I, O, E> JsonRpcMethodErased<'a> for JsonRpcMethod<'_, I, O, E>where
I: DeserializeOwned + Serialize,
O: DeserializeOwned + Serialize,
E: DeserializeOwned + Serialize,
fn name(&'a self) -> &str
fn create_request( &self, params: Vec<u8>, json_rpc_id: JsonRpcId, ) -> Result<JsonRpcRequestErased, Error>
fn parse_json_response_str( &self, json_str: &str, ) -> Result<JsonRpcResponseErased, Error>
fn parse_json_response_value( &self, json_value: Value, ) -> Result<JsonRpcResponseErased, Error>
Source§impl<'a, I, O, E> JsonRpcMethodUnerased<'a, I, O, E> for JsonRpcMethod<'a, I, O, E>where
O: DeserializeOwned,
E: DeserializeOwned,
Dummy implementation for when the user uses the generic api
impl<'a, I, O, E> JsonRpcMethodUnerased<'a, I, O, E> for JsonRpcMethod<'a, I, O, E>where
O: DeserializeOwned,
E: DeserializeOwned,
Dummy implementation for when the user uses the generic api
fn name(&self) -> &str
fn create_request( &self, params: I, json_rpc_id: JsonRpcId, ) -> Result<JsonRpcRequest<I>, Error>
fn parse_json_response_str( &self, json_str: &str, ) -> Result<JsonRpcResponse<O, E>, Error>
fn parse_json_response_value( &self, json_value: Value, ) -> Result<JsonRpcResponse<O, E>, Error>
Source§impl<'a, I, O, E> Serialize for JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> Serialize for JsonRpcMethod<'a, I, O, E>
impl<'a, I: Copy, O: Copy, E: Copy> Copy for JsonRpcMethod<'a, I, O, E>
Auto Trait Implementations§
impl<'a, I, O, E> Freeze for JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> RefUnwindSafe for JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> Send for JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> Sync for JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> Unpin for JsonRpcMethod<'a, I, O, E>
impl<'a, I, O, E> UnwindSafe for JsonRpcMethod<'a, I, O, E>
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