Skip to main content

Host

Trait Host 

Source
pub trait Host: Send {
    // Required methods
    fn iana_id(&mut self) -> impl Future<Output = Result<Option<String>>> + Send;
    fn utc_offset(
        &mut self,
        when: Instant,
    ) -> impl Future<Output = Result<Option<i64>>> + Send;
    fn to_debug_string(&mut self) -> impl Future<Output = Result<String>> + Send;
}

Required Methods§

Source

fn iana_id(&mut self) -> impl Future<Output = Result<Option<String>>> + Send

Return the IANA identifier of the currently configured timezone. This should be an identifier from the IANA Time Zone Database.

For displaying to a user, the identifier should be converted into a localized name by means of an internationalization API.

If the implementation does not expose an actual timezone, or is unable to provide mappings from times to deltas between the configured timezone and UTC, or determining the current timezone fails, or the timezone does not have an IANA identifier, this returns nothing.

Source

fn utc_offset( &mut self, when: Instant, ) -> impl Future<Output = Result<Option<i64>>> + Send

The number of nanoseconds difference between UTC time and the local time of the currently configured timezone, at the exact time of instant.

The magnitude of the returned value will always be less than 86,400,000,000,000 which is the number of nanoseconds in a day (246060*1e9).

If the implementation does not expose an actual timezone, or is unable to provide mappings from times to deltas between the configured timezone and UTC, or determining the current timezone fails, this returns nothing.

Source

fn to_debug_string(&mut self) -> impl Future<Output = Result<String>> + Send

Returns a string that is suitable to assist humans in debugging whether any timezone is available, and if so, which. This may be the same string as iana-id, or a formatted representation of the UTC offset such as -04:00, or something else.

WARNING: The returned string should not be consumed mechanically! It may change across platforms, hosts, or other implementation details. Parsing this string is a major platform-compatibility hazard.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<_T: Host + ?Sized + Send> Host for &mut _T

Source§

fn iana_id(&mut self) -> impl Future<Output = Result<Option<String>>> + Send

Return the IANA identifier of the currently configured timezone. This should be an identifier from the IANA Time Zone Database.

For displaying to a user, the identifier should be converted into a localized name by means of an internationalization API.

If the implementation does not expose an actual timezone, or is unable to provide mappings from times to deltas between the configured timezone and UTC, or determining the current timezone fails, or the timezone does not have an IANA identifier, this returns nothing.

Source§

fn utc_offset( &mut self, when: Instant, ) -> impl Future<Output = Result<Option<i64>>> + Send

The number of nanoseconds difference between UTC time and the local time of the currently configured timezone, at the exact time of instant.

The magnitude of the returned value will always be less than 86,400,000,000,000 which is the number of nanoseconds in a day (246060*1e9).

If the implementation does not expose an actual timezone, or is unable to provide mappings from times to deltas between the configured timezone and UTC, or determining the current timezone fails, this returns nothing.

Source§

fn to_debug_string(&mut self) -> impl Future<Output = Result<String>> + Send

Returns a string that is suitable to assist humans in debugging whether any timezone is available, and if so, which. This may be the same string as iana-id, or a formatted representation of the UTC offset such as -04:00, or something else.

WARNING: The returned string should not be consumed mechanically! It may change across platforms, hosts, or other implementation details. Parsing this string is a major platform-compatibility hazard.

Implementors§