pub trait ParseResponseErrorCode {
    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§

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);

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)));

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);

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§

Implementors§