#[non_exhaustive]pub enum Error {
InvalidUtcWithNamedTz {
tz: String,
},
InvalidIanaName(String),
InvalidFormat(String),
Io(Error),
}Expand description
Errors raised by the rusty-ts library API.
Marked #[non_exhaustive] to allow new variants in minor releases.
§Example
use rusty_ts::{Error, TimestamperBuilder};
// Pattern-match on specific variants for actionable handling.
let result = TimestamperBuilder::new()
.utc(true)
.tz_name("Asia/Tokyo")
.build();
match result {
Err(Error::InvalidUtcWithNamedTz { tz }) => {
eprintln!("cannot combine -u with --tz={tz}");
}
Err(Error::InvalidIanaName(name)) => {
eprintln!("unknown IANA timezone: {name}");
}
Err(other) => eprintln!("error: {other}"),
Ok(_) => unreachable!("we configured a conflict"),
}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.
InvalidUtcWithNamedTz
-u (UTC) and --tz=<name> were both specified, which is invalid.
Mirrors the CLI-layer FR-020 mutual-exclusion check at the library
layer so library consumers do not depend on the CLI to catch it.
InvalidIanaName(String)
The named IANA timezone could not be resolved (e.g., typo, removed zone). Carries the offending input.
InvalidFormat(String)
The strftime format string is malformed or unsupported. Carries the offending format string.
Io(Error)
Underlying IO error, surfaced from BufRead/Write operations.
Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()
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