Trait ParseResponseErrorCode

Source
pub trait ParseResponseErrorCode {
    // Required methods
    fn ok(self) -> Option<()>;
    fn err(self) -> Option<ResponseError>;
    fn is_ok(&self) -> bool;
    fn is_err(&self) -> bool;
}
Expand description

A trait providing tools for parsing Kafka response error code.

Required Methods§

Source

fn ok(self) -> Option<()>

Convert from an i16 error code to Option<()>, if is ok, returns Some(()).

Convert self into an Option<()>, consuming self, and discarding the error code, if any.

§Examples
use kafka_protocol::error::ParseResponseErrorCode;

assert_eq!(0.ok(), Some(()));
assert_eq!((-1).ok(), None);
assert_eq!(100.ok(), None);
assert_eq!(1000.ok(), None);
Source

fn err(self) -> Option<ResponseError>

Convert from an i16 error code to Option<ResponseError>, if is error, returns Some(ResponseError)

Convert self into an Option, consuming self, and discarding the success value, if any.

§Examples
use kafka_protocol::error::{
    ParseResponseErrorCode,
    ResponseError,
};

assert_eq!(0.err(), None);
assert_eq!((-1).err(), Some(ResponseError::UnknownServerError));
assert_eq!(100.err(), Some(ResponseError::UnknownTopicId));
assert_eq!(1000.err(), Some(ResponseError::Unknown(1000)));
Source

fn is_ok(&self) -> bool

Returns true if the result is ok.

§Examples
use kafka_protocol::error::ParseResponseErrorCode;

assert_eq!(0.is_ok(), true);
assert_eq!((-1).is_ok(), false);
assert_eq!(100.is_ok(), false);
assert_eq!(1000.is_ok(), false);
Source

fn is_err(&self) -> bool

Returns true if the result is error.

§Examples
use kafka_protocol::error::ParseResponseErrorCode;

assert_eq!(0.is_err(), false);
assert_eq!((-1).is_err(), true);
assert_eq!(100.is_err(), true);
assert_eq!(1000.is_err(), true);

Implementations on Foreign Types§

Source§

impl ParseResponseErrorCode for i16

Source§

fn ok(self) -> Option<()>

Source§

fn err(self) -> Option<ResponseError>

Source§

fn is_ok(&self) -> bool

Source§

fn is_err(&self) -> bool

Implementors§