Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { Io(Error), Timeout(TimeoutError), Protocol(ProtocolError), Config(ConfigError), Http(Error), External(BoxError), }
Expand description

Top-level error type.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Io(Error)

Transport-level I/O error (TCP read/write/connect).

§

Timeout(TimeoutError)

Operation exceeded a configured deadline.

§

Protocol(ProtocolError)

Wire-protocol failure (parsing, headers, encapsulation, etc.).

§

Config(ConfigError)

Builder / configuration failure (invalid service options, unknown alias, missing handlers, …).

§

Http(Error)

Error returned by the http crate builders.

§

External(BoxError)

Error from outside this crate, preserved via ToIcapResult or Error::external. The original error is available through source().

Implementations§

Source§

impl Error

Source

pub const fn is_io(&self) -> bool

True if the error originates from an I/O failure on the transport.

Source

pub const fn is_timeout(&self) -> bool

True if the error originates from a deadline (any TimeoutKind).

Source

pub const fn is_protocol(&self) -> bool

True if the error came from the wire protocol layer.

Source

pub const fn is_body_too_large(&self) -> bool

True if the peer sent an embedded body larger than a configured limit.

Source

pub const fn is_config(&self) -> bool

True if the error came from builder / configuration validation.

Source

pub const fn is_early_close(&self) -> bool

True for the “peer closed before headers” case — common on kept-alive connections that the server has idle-closed.

Source

pub const fn is_retryable(&self) -> bool

True if a fresh attempt is likely to succeed.

Conservative: connection-establishment timeouts, idle keep-alive closure, and EarlyClose are considered retryable. Application-level protocol errors are not retryable — the peer will reject the same bytes again.

Source

pub fn parse(message: impl Into<String>) -> Self

Build a protocol parse error.

Source

pub fn http_parse(message: impl Into<String>) -> Self

Build an embedded-HTTP parse error.

Source

pub fn header(message: impl Into<String>) -> Self

Build a generic header error.

Source

pub fn body(message: impl Into<String>) -> Self

Build a body error.

Source

pub const fn body_too_large(size: usize, max: usize) -> Self

Build an oversized-body protocol error.

Source

pub fn serialization(message: impl Into<String>) -> Self

Build a serialization error.

Source

pub fn service(message: impl Into<String>) -> Self

Build a service / configuration error.

Source

pub const fn missing_header(name: &'static str) -> Self

Build a “missing required header” protocol error.

Source

pub fn invalid_istag(value: impl Into<String>) -> Self

Build an “invalid ISTag” protocol error.

Source

pub fn invalid_status_code(value: impl Into<String>) -> Self

Build an “invalid status code” protocol error.

Source

pub fn invalid_method(value: impl Into<String>) -> Self

Build an “invalid method” protocol error.

Source

pub fn invalid_uri(value: impl Into<String>) -> Self

Build an “invalid URI” protocol error.

Source

pub fn invalid_version(value: impl Into<String>) -> Self

Build an “invalid protocol version” protocol error.

Source

pub fn external<E>(err: E) -> Self
where E: StdError + Send + Sync + 'static,

Build an External error from any std::error::Error.

Source

pub fn unexpected(message: impl Into<String>) -> Self

Build an External error from an ad-hoc message string.

Source

pub const fn timeout(kind: TimeoutKind, duration: Duration) -> Self

Build a Timeout from a kind + duration.

Source

pub const fn client_total_timeout(d: Duration) -> Self

Source

pub const fn client_connect_timeout(d: Duration) -> Self

Source

pub const fn client_write_timeout(d: Duration) -> Self

Source

pub const fn client_continue_timeout(d: Duration) -> Self

Source

pub const fn server_header_read_timeout(d: Duration) -> Self

Source

pub const fn server_body_read_timeout(d: Duration) -> Self

Source

pub const fn server_write_timeout(d: Duration) -> Self

Source

pub const fn server_idle_timeout(d: Duration) -> Self

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<ConfigError> for Error

Source§

fn from(source: ConfigError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(source: HttpError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(err: Error) -> Self

Converts to this type from the input type.
Source§

impl From<FromUtf8Error> for Error

Source§

fn from(e: FromUtf8Error) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidHeaderName> for Error

Source§

fn from(e: InvalidHeaderName) -> Self

Converts to this type from the input type.
Source§

impl From<InvalidHeaderValue> for Error

Source§

fn from(e: InvalidHeaderValue) -> Self

Converts to this type from the input type.
Source§

impl From<ProtocolError> for Error

Source§

fn from(source: ProtocolError) -> Self

Converts to this type from the input type.
Source§

impl From<TimeoutError> for Error

Source§

fn from(source: TimeoutError) -> Self

Converts to this type from the input type.
Source§

impl From<ToStrError> for Error

Source§

fn from(e: ToStrError) -> Self

Converts to this type from the input type.
Source§

impl From<Utf8Error> for Error

Source§

fn from(e: Utf8Error) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Error

§

impl !UnwindSafe for Error

§

impl Freeze for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more