Trait reth_rpc_server_types::result::ToRpcResult
source · pub trait ToRpcResult<Ok, Err>: Sized {
// Required methods
fn map_rpc_err<'a, F, M>(self, op: F) -> RpcResult<Ok>
where F: FnOnce(Err) -> (i32, M, Option<&'a [u8]>),
M: Into<String>;
fn map_internal_err<F, M>(self, op: F) -> RpcResult<Ok>
where F: FnOnce(Err) -> M,
M: Into<String>;
fn map_internal_err_with_data<'a, F, M>(self, op: F) -> RpcResult<Ok>
where F: FnOnce(Err) -> (M, &'a [u8]),
M: Into<String>;
fn with_message(self, msg: &str) -> RpcResult<Ok>;
// Provided method
fn to_rpc_result(self) -> RpcResult<Ok>
where Err: Display { ... }
}
Expand description
Helper trait to easily convert various Result
types into [RpcResult
]
Required Methods§
sourcefn map_rpc_err<'a, F, M>(self, op: F) -> RpcResult<Ok>
fn map_rpc_err<'a, F, M>(self, op: F) -> RpcResult<Ok>
Converts this type into an [RpcResult
]
sourcefn map_internal_err<F, M>(self, op: F) -> RpcResult<Ok>
fn map_internal_err<F, M>(self, op: F) -> RpcResult<Ok>
Converts this type into an [RpcResult
] with the
[jsonrpsee_types::error::INTERNAL_ERROR_CODE
] and the given message.
sourcefn map_internal_err_with_data<'a, F, M>(self, op: F) -> RpcResult<Ok>
fn map_internal_err_with_data<'a, F, M>(self, op: F) -> RpcResult<Ok>
Converts this type into an [RpcResult
] with the
[jsonrpsee_types::error::INTERNAL_ERROR_CODE
] and given message and data.
sourcefn with_message(self, msg: &str) -> RpcResult<Ok>
fn with_message(self, msg: &str) -> RpcResult<Ok>
Adds a message to the error variant and returns an internal Error.
This is shorthand for Self::map_internal_err(|err| format!("{msg}: {err}"))
.
Provided Methods§
sourcefn to_rpc_result(self) -> RpcResult<Ok>where
Err: Display,
fn to_rpc_result(self) -> RpcResult<Ok>where
Err: Display,
Converts result to [RpcResult
] by converting error variant to
[jsonrpsee_types::error::ErrorObject
]
Object Safety§
This trait is not object safe.