#[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.
BencodeSyntax
Bencode syntax is invalid.
Fields
BencodeCanonical
Bencode is parseable but not canonical.
Fields
Metainfo
A metainfo field is invalid.
ResourceLimit
A parser or allocation resource limit was exceeded.
Fields
Unsupported
A requested feature or policy is unsupported.
Verification
Payload verification found a mismatch.
Fields
Cancelled
The operation was cancelled.
Implementations§
Source§impl Error
impl Error
Sourcepub fn io(path: impl Into<PathBuf>, source: Error) -> Self
pub fn io(path: impl Into<PathBuf>, source: Error) -> Self
Creates an I/O error with path context.
Sourcepub fn bencode_syntax(offset: usize, message: impl Into<String>) -> Self
pub fn bencode_syntax(offset: usize, message: impl Into<String>) -> Self
Creates a bencode syntax error.
Sourcepub fn bencode_canonical(offset: usize, message: impl Into<String>) -> Self
pub fn bencode_canonical(offset: usize, message: impl Into<String>) -> Self
Creates a canonical bencode error.
Sourcepub fn metainfo_field(
field: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn metainfo_field( field: impl Into<String>, message: impl Into<String>, ) -> Self
Creates a metainfo field error.
Sourcepub fn unsupported(message: impl Into<String>) -> Self
pub fn unsupported(message: impl Into<String>) -> Self
Creates an unsupported-feature error.
Sourcepub fn verification_mismatch(
path: Option<PathBuf>,
message: impl Into<String>,
) -> Self
pub fn verification_mismatch( path: Option<PathBuf>, message: impl Into<String>, ) -> Self
Creates a payload verification mismatch.
Sourcepub const fn category(&self) -> ErrorCategory
pub const fn category(&self) -> ErrorCategory
Returns the stable category for this error.
Sourcepub const fn limit(&self) -> Option<&'static str>
pub const fn limit(&self) -> Option<&'static str>
Returns the stable resource-limit name, when present.
Sourcepub const fn actual_and_maximum(&self) -> Option<(usize, usize)>
pub const fn actual_and_maximum(&self) -> Option<(usize, usize)>
Returns the observed and maximum resource amounts, when present.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn StdError + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more