zebra_rpc::server::error

Trait OkOrError

source
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§

source

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§

source

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.

Implementations on Foreign Types§

source§

impl<T> OkOrError<T> for Option<T>

source§

fn ok_or_error( self, code: impl Into<ErrorCode>, message: impl ToString, ) -> Result<T, ErrorObjectOwned>

Implementors§