Skip to main content

ExtractField

Enum ExtractField 

Source
pub enum ExtractField {
Show 22 variants Microseconds, Milliseconds, Second, Minute, Hour, Day, Week, Month, Quarter, Year, Decade, Century, Millennium, DayOfWeek, IsoDayOfWeek, DayOfYear, IsoYear, Epoch, Julian, Timezone, TimezoneHour, TimezoneMinute,
}
Expand description

A field extract and date_part take, printed as PostgreSQL spells it in its errors.

use sql_values::postgres::ExtractField;

assert_eq!(ExtractField::parse("SECS"), Some(ExtractField::Second));
assert_eq!(ExtractField::parse("timezone_hour"), Some(ExtractField::TimezoneHour));
assert_eq!(ExtractField::DayOfWeek.to_string(), "dow");
assert_eq!(ExtractField::parse("fortnight"), None);

Variants§

§

Microseconds

microseconds, the seconds with their fraction, in microseconds.

§

Milliseconds

milliseconds, the seconds with their fraction, in milliseconds.

§

Second

second, the seconds with their fraction.

§

Minute

minute.

§

Hour

hour.

§

Day

day, of the month, or an interval’s days.

§

Week

week, the ISO 8601 week of the year, or an interval’s days in whole weeks.

§

Month

month, of the year, or an interval’s months beyond its whole years.

§

Quarter

quarter.

§

Year

year, where 1 BC is -1.

§

Decade

decade, the year divided by 10.

§

Century

century, where the 21st starts on 2001-01-01.

§

Millennium

millennium, where the 3rd starts on 2001-01-01.

§

DayOfWeek

dow, the day of the week from Sunday as 0.

§

IsoDayOfWeek

isodow, the day of the week from Monday as 1 to Sunday as 7.

§

DayOfYear

doy, the day of the year from 1.

§

IsoYear

isoyear, the ISO 8601 week-numbering year.

§

Epoch

epoch, seconds since 1970-01-01 00:00:00 UTC, or an interval’s length in seconds.

§

Julian

julian, the Julian day with the time of day as its fraction.

§

Timezone

timezone, the offset east of UTC in seconds.

§

TimezoneHour

timezone_hour, the whole hours of the offset.

§

TimezoneMinute

timezone_minute, the minutes of the offset beyond its whole hours.

Implementations§

Source§

impl ExtractField

Source

pub fn parse(text: &str) -> Option<Self>

The field PostgreSQL reads text as, lowercased and looked up by its first 10 bytes among the interval units and then the date keywords, so aliases such as secs, msec, y, j and timezone_h name fields too. None for any other word, which PostgreSQL refuses as not recognized, or as not supported by date and timestamp when it is a reserved word such as now.

Trait Implementations§

Source§

impl Clone for ExtractField

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for ExtractField

Source§

impl Debug for ExtractField

Source§

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

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

impl Display for ExtractField

Source§

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

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

impl Eq for ExtractField

Source§

impl Hash for ExtractField

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ExtractField

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 ExtractField

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.