timezone_data/error.rs
1//! Error type for timezone data parsing and lookup.
2
3use core::fmt;
4
5/// Errors produced when loading or parsing timezone data.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum Error {
9 /// The requested zone was not found in the embedded database.
10 NotFound,
11 /// A POSIX TZ string could not be parsed. The payload is a short reason.
12 BadPosixTz(&'static str),
13}
14
15impl fmt::Display for Error {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 match self {
18 Error::NotFound => f.write_str("timezone not found in embedded data"),
19 Error::BadPosixTz(why) => write!(f, "malformed POSIX TZ string: {why}"),
20 }
21 }
22}
23
24impl core::error::Error for Error {}