SunriseResult

Enum SunriseResult 

Source
pub enum SunriseResult<T = ()> {
    RegularDay {
        sunrise: T,
        transit: T,
        sunset: T,
    },
    AllDay {
        transit: T,
    },
    AllNight {
        transit: T,
    },
}
Expand description

Result of sunrise/sunset calculations for a given day.

Solar events can vary significantly based on location and time of year, especially at extreme latitudes where polar days and nights occur. Default generic parameter is (); chrono helpers return SunriseResult<chrono::DateTime<Tz>>.

Variants§

§

RegularDay

Regular day with distinct sunrise, transit (noon), and sunset times

Fields

§sunrise: T

Time of sunrise

§transit: T

Time of solar transit (when sun crosses meridian, solar noon)

§sunset: T

Time of sunset

§

AllDay

Polar day - sun remains above the specified horizon all day

Fields

§transit: T

Time of solar transit (closest approach to zenith)

§

AllNight

Polar night - sun remains below the specified horizon all day

Fields

§transit: T

Time of solar transit (when sun is highest, though still below horizon)

Implementations§

Source§

impl<T> SunriseResult<T>

Source

pub const fn transit(&self) -> &T

Gets the transit time (solar noon) for any sunrise result.

Source

pub const fn is_regular_day(&self) -> bool

Checks if this represents a regular day with sunrise and sunset.

Source

pub const fn is_polar_day(&self) -> bool

Checks if this represents a polar day (sun never sets).

Source

pub const fn is_polar_night(&self) -> bool

Checks if this represents a polar night (sun never rises).

Source

pub const fn sunrise(&self) -> Option<&T>

Gets sunrise time if this is a regular day.

Source

pub const fn sunset(&self) -> Option<&T>

Gets sunset time if this is a regular day.

Trait Implementations§

Source§

impl<T: Clone> Clone for SunriseResult<T>

Source§

fn clone(&self) -> SunriseResult<T>

Returns a duplicate of the value. Read more
1.0.0§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for SunriseResult<T>

Source§

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

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

impl<T: PartialEq> PartialEq for SunriseResult<T>

Source§

fn eq(&self, other: &SunriseResult<T>) -> bool

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

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<T: Eq> Eq for SunriseResult<T>

Source§

impl<T> StructuralPartialEq for SunriseResult<T>

Auto Trait Implementations§

§

impl<T> Freeze for SunriseResult<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SunriseResult<T>
where T: RefUnwindSafe,

§

impl<T> Send for SunriseResult<T>
where T: Send,

§

impl<T> Sync for SunriseResult<T>
where T: Sync,

§

impl<T> Unpin for SunriseResult<T>
where T: Unpin,

§

impl<T> UnwindSafe for SunriseResult<T>
where T: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.