Skip to main content

TzifFile

Struct TzifFile 

Source
pub struct TzifFile {
    pub version: Version,
    pub v1: DataBlock,
    pub v2_plus: Option<DataBlock>,
    pub footer: Option<String>,
}

Fields§

§version: Version§v1: DataBlock§v2_plus: Option<DataBlock>§footer: Option<String>

Implementations§

Source§

impl TzifFile

Source

pub fn interoperability_warnings( &self, ) -> Result<Vec<InteroperabilityWarning>, TzifError>

Returns interoperability warnings for readers with common legacy TZif limitations.

§Errors

Returns an error if the file is not structurally valid.

Source§

impl TzifFile

Source

pub const fn v1(block: DataBlock) -> Self

Source

pub fn v2(v1: DataBlock, v2: DataBlock, footer: impl Into<String>) -> Self

Source

pub fn v3(v1: DataBlock, v3: DataBlock, footer: impl Into<String>) -> Self

Source

pub fn v4(v1: DataBlock, v4: DataBlock, footer: impl Into<String>) -> Self

Source

pub fn validate(&self) -> Result<(), TzifError>

Validates this file against the structural TZif rules implemented by this crate.

§Errors

Returns an error when the file contains invalid counts, indexes, version-specific data, footer content, or leap-second records.

Source§

impl TzifFile

Source

pub fn parse(input: &[u8]) -> Result<Self, TzifError>

Parses a TZif byte slice into a validated file.

§Errors

Returns an error if the input is malformed, truncated, has invalid counts or indexes, or fails semantic validation.

Source§

impl TzifFile

Source

pub fn has_leap_seconds(&self) -> bool

Source

pub fn suggested_media_type(&self) -> &'static str

Source

pub fn validate_for_media_type( &self, media_type: TzifMediaType, ) -> Result<(), TzdistError>

Validates that this file can be served as the requested media type.

§Errors

Returns an error if the file is invalid, or if leap seconds are present in an application/tzif response.

Source

pub fn validate_tzdist_truncation( &self, truncation: TzdistTruncation, ) -> Result<(), TzdistError>

Validates the structural TZif requirements for a TZDIST truncation response.

§Errors

Returns an error if the file is not version 2 or later, lacks required transitions, has mismatched truncation boundaries, or does not use the required -00 placeholder types.

Source§

impl TzifFile

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, TzifError>

Encodes this file to TZif bytes after validating it.

§Errors

Returns an error if the file is invalid or contains counts or timestamps that cannot be represented by the selected TZif version.

Trait Implementations§

Source§

impl Clone for TzifFile

Source§

fn clone(&self) -> TzifFile

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TzifFile

Source§

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

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

impl PartialEq for TzifFile

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TzifFile

Source§

impl StructuralPartialEq for TzifFile

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.