pub struct Error { /* private fields */ }Expand description
Crate-wide error type.
Implementations§
Source§impl Error
impl Error
Sourcepub const fn not_recognized() -> Self
pub const fn not_recognized() -> Self
Sourcepub const fn unsupported_encoding() -> Self
pub const fn unsupported_encoding() -> Self
Creates an unsupported-encoding error.
§Returns
An Error wrapping RecognitionFailure::UnsupportedEncoding.
Sourcepub const fn malformed_container() -> Self
pub const fn malformed_container() -> Self
Creates a malformed-container error.
§Returns
An Error wrapping RecognitionFailure::MalformedContainer.
Sourcepub const fn limit_exceeded() -> Self
pub const fn limit_exceeded() -> Self
Sourcepub const fn crypto_mismatch() -> Self
pub const fn crypto_mismatch() -> Self
Sourcepub const fn compression_error() -> Self
pub const fn compression_error() -> Self
Sourcepub const fn token_error() -> Self
pub const fn token_error() -> Self
Sourcepub const fn recognition_failure(&self) -> Option<RecognitionFailure>
pub const fn recognition_failure(&self) -> Option<RecognitionFailure>
Returns the recognition failure when this error represents one.
§Returns
Some with the wrapped RecognitionFailure; currently every Error
carries one, so this never returns None.
Examples found in repository?
examples/dump.rs (line 37)
7fn main() -> ExitCode {
8 let mut args = env::args_os();
9 let _program = args.next();
10 let mut path = None;
11 for arg in args {
12 if path.is_none() {
13 path = Some(arg);
14 } else {
15 eprintln!("usage: dump <autoit-exe-or-a3x>");
16 return ExitCode::FAILURE;
17 }
18 }
19 let Some(path) = path else {
20 eprintln!("usage: dump <autoit-exe-or-a3x>");
21 return ExitCode::FAILURE;
22 };
23
24 let data = match fs::read(&path) {
25 Ok(data) => data,
26 Err(err) => {
27 eprintln!("failed to read input: {err}");
28 return ExitCode::FAILURE;
29 }
30 };
31
32 match AutoItBinary::try_parse(&data) {
33 Ok(binary) => {
34 print_text(&binary);
35 ExitCode::SUCCESS
36 }
37 Err(err) if err.recognition_failure() == Some(RecognitionFailure::NotRecognized) => {
38 eprintln!("not recognized as AutoIt");
39 ExitCode::FAILURE
40 }
41 Err(err) => {
42 eprintln!("failed to parse AutoIt payload: {err}");
43 ExitCode::FAILURE
44 }
45 }
46}Trait Implementations§
Source§impl Display for Error
impl Display for Error
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Formats the error by delegating to its wrapped RecognitionFailure.
§Arguments
f- The formatter to write into.
§Returns
A fmt::Result propagating any formatter write error.
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<TokenError> for Error
impl From<TokenError> for Error
Source§fn from(_value: TokenError) -> Self
fn from(_value: TokenError) -> Self
Converts a TokenError into the crate-level Error.
All token-parsing failures collapse into a single token error; the
specific TokenError variant is not preserved.
§Arguments
_value- TheTokenErrorto convert (its variant is discarded).
§Returns
The crate Error produced by Error::token_error.
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin 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