Skip to main content

TzEnv

Enum TzEnv 

Source
pub enum TzEnv {
    Rule(TimeZone),
    Implementation(TimeZoneId),
}
Expand description

The result of parsing the POSIX TZ environment variable.

A TZ variable can either be a POSIX time zone string with an optional DST transition rule, or it can begin with a : followed by an arbitrary set of bytes that is implementation defined.

In practice, the content following a : is treated as an IANA time zone name. Moreover, even if the TZ string doesn’t start with a : but corresponds to a IANA time zone name, then it is interpreted as such. However, this type only encapsulates the choices strictly provided by POSIX: either a time zone string with an optional DST transition rule, or an implementation defined string with a : prefix. If, for example, TZ="America/New_York", then that case isn’t encapsulated by this type. Callers needing that functionality will need to handle the error returned by parsing this type and layer their own semantics on top. In general, any valid IANA time zone identifier will be an invalid POSIX time zone string.

Variants§

§

Rule(TimeZone)

A valid POSIX time zone with an optional DST transition rule.

§

Implementation(TimeZoneId)

An implementation defined string. This occurs when the TZ value starts with a :. The string stored here does not include the :.

Typically this is an IANA time zone identifier.

Implementations§

Source§

impl TzEnv

Source

pub fn parse<B: AsRef<[u8]>>(bytes: B) -> Result<TzEnv, ParseError>

Parse a POSIX TZ environment variable string from the given bytes.

Source

pub fn parse_os_str<O: AsRef<OsStr>>(osstr: O) -> Result<TzEnv, ParseError>

Parse a POSIX TZ environment variable string from the given OsStr.

Trait Implementations§

Source§

impl Debug for TzEnv

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TzEnv

Source§

impl PartialEq for TzEnv

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TzEnv

Auto Trait Implementations§

§

impl Forget for TzEnv

§

impl Freeze for TzEnv

§

impl Move for TzEnv

§

impl RefUnwindSafe for TzEnv

§

impl Send for TzEnv

§

impl Sync for TzEnv

§

impl Unpin for TzEnv

§

impl UnsafeUnpin for TzEnv

§

impl UnwindSafe for TzEnv

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.