pub(crate) trait OkOrError<T>: Sized {
// Required method
fn ok_or_error(
self,
code: impl Into<ErrorCode>,
message: impl ToString,
) -> Result<T, ErrorObjectOwned>;
// Provided method
fn ok_or_misc_error(
self,
message: impl ToString,
) -> Result<T, ErrorObjectOwned> { ... }
}
Expand description
A trait for conditionally converting a value into a Result<T, jsonrpc_core::Error>
.
Required Methods§
sourcefn ok_or_error(
self,
code: impl Into<ErrorCode>,
message: impl ToString,
) -> Result<T, ErrorObjectOwned>
fn ok_or_error( self, code: impl Into<ErrorCode>, message: impl ToString, ) -> Result<T, ErrorObjectOwned>
Converts the implementing type to Result<T, jsonrpc_core::Error>
, using an error code and
message if conversion is to Err
.
Provided Methods§
sourcefn ok_or_misc_error(self, message: impl ToString) -> Result<T, ErrorObjectOwned>
fn ok_or_misc_error(self, message: impl ToString) -> Result<T, ErrorObjectOwned>
Converts the implementing type to Result<T, jsonrpc_core::Error>
, using a LegacyCode::Misc
error code.
Object Safety§
This trait is not object safe.