Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error { Io { path: PathBuf, source: Error, }, BencodeSyntax { offset: usize, message: String, }, BencodeCanonical { offset: usize, message: String, }, Metainfo { field: String, message: String, }, ResourceLimit { limit: &'static str, actual: usize, maximum: usize, }, Unsupported { message: String, }, Verification { path: Option<PathBuf>, message: String, }, Cancelled, }
Expand description

Errors returned by the BTPC core library.

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

An I/O operation failed for a path.

Fields

§path: PathBuf

Path associated with the failed operation.

§source: Error

Underlying I/O error.

§

BencodeSyntax

Bencode syntax is invalid.

Fields

§offset: usize

Byte offset where the violation was detected.

§message: String

Human-readable explanation.

§

BencodeCanonical

Bencode is parseable but not canonical.

Fields

§offset: usize

Byte offset where the violation was detected.

§message: String

Human-readable explanation.

§

Metainfo

A metainfo field is invalid.

Fields

§field: String

Dot-separated bencode field path.

§message: String

Human-readable explanation.

§

ResourceLimit

A parser or allocation resource limit was exceeded.

Fields

§limit: &'static str

Stable name of the configured limit.

§actual: usize

Observed or requested amount.

§maximum: usize

Configured maximum amount.

§

Unsupported

A requested feature or policy is unsupported.

Fields

§message: String

Human-readable explanation.

§

Verification

Payload verification found a mismatch.

Fields

§path: Option<PathBuf>

Optional payload path associated with the mismatch.

§message: String

Human-readable explanation.

§

Cancelled

The operation was cancelled.

Implementations§

Source§

impl Error

Source

pub fn io(path: impl Into<PathBuf>, source: Error) -> Self

Creates an I/O error with path context.

Source

pub fn bencode_syntax(offset: usize, message: impl Into<String>) -> Self

Creates a bencode syntax error.

Source

pub fn bencode_canonical(offset: usize, message: impl Into<String>) -> Self

Creates a canonical bencode error.

Source

pub fn metainfo_field( field: impl Into<String>, message: impl Into<String>, ) -> Self

Creates a metainfo field error.

Source

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

Creates an unsupported-feature error.

Source

pub fn verification_mismatch( path: Option<PathBuf>, message: impl Into<String>, ) -> Self

Creates a payload verification mismatch.

Source

pub const fn cancelled() -> Self

Creates a cancellation error.

Source

pub const fn category(&self) -> ErrorCategory

Returns the stable category for this error.

Source

pub const fn offset(&self) -> Option<usize>

Returns the associated byte offset, when present.

Source

pub fn field(&self) -> Option<&str>

Returns the associated metainfo field path, when present.

Source

pub fn path(&self) -> Option<&Path>

Returns the associated filesystem path, when present.

Source

pub const fn limit(&self) -> Option<&'static str>

Returns the stable resource-limit name, when present.

Source

pub const fn actual_and_maximum(&self) -> Option<(usize, usize)>

Returns the observed and maximum resource amounts, when present.

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 StdError + '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

Auto Trait Implementations§

§

impl Freeze for Error

§

impl !RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl !UnwindSafe 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, 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> Same for T

Source§

type Output = T

Should always be Self
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.