pub struct BirthDate(/* private fields */);date only.Expand description
Tug’ilgan sana: MIN_YEAR dan keyin va (yaratilish paytida) kelajakda emas.
Kelajak tekshiruvi monoton: bir marta qabul qilingan sana keyinchalik hech
qachon rad etilmaydi — shuning uchun replay/Deserialize uchun xavfsiz.
Deterministik testlar uchun *_at(…, today) variantlari bor.
MIN_YEAR — sanity floor, biznes qoidasi emas: yosh chegarasini
(>= 18, <= 120 va h.k.) age_at bilan ilova qatlamida qo’ying.
Implementations§
Source§impl BirthDate
impl BirthDate
Sourcepub const DEFAULT_FORMAT: DateFormat = DateFormat::YmdHyphen
pub const DEFAULT_FORMAT: DateFormat = DateFormat::YmdHyphen
Standart format.
Sourcepub const MIN_YEAR: i32 = 1800
pub const MIN_YEAR: i32 = 1800
Eng erta qabul qilinadigan yil.
1800 — chunki PINFL 1-raqami 1/2 bo’lganda asr 1800 bo’ladi
(Pinfl::century); 1900 da Pinfl::birth_date
bunday PINFL uchun har doim None qaytarardi.
Sourcepub fn parse(value: &str) -> Result<Self, BirthDateError>
pub fn parse(value: &str) -> Result<Self, BirthDateError>
YYYY-MM-DD dan (bugun = UTC).
Sourcepub fn parse_with_format(
value: &str,
format: DateFormat,
) -> Result<Self, BirthDateError>
pub fn parse_with_format( value: &str, format: DateFormat, ) -> Result<Self, BirthDateError>
Berilgan formatdan (bugun = UTC).
Sourcepub fn parse_with_format_at(
value: &str,
format: DateFormat,
today: NaiveDate,
) -> Result<Self, BirthDateError>
pub fn parse_with_format_at( value: &str, format: DateFormat, today: NaiveDate, ) -> Result<Self, BirthDateError>
Deterministik variant: “bugun” tashqaridan beriladi.
Sourcepub fn from_naive_date(date: NaiveDate) -> Result<Self, BirthDateError>
pub fn from_naive_date(date: NaiveDate) -> Result<Self, BirthDateError>
NaiveDate dan (bugun = UTC).
Sourcepub fn from_naive_date_at(
date: NaiveDate,
today: NaiveDate,
) -> Result<Self, BirthDateError>
pub fn from_naive_date_at( date: NaiveDate, today: NaiveDate, ) -> Result<Self, BirthDateError>
NaiveDate dan, deterministik. Yuqori chegara: today + 1 (UTC+14 gacha yon berish).
Sourcepub fn as_naive_date(&self) -> NaiveDate
pub fn as_naive_date(&self) -> NaiveDate
Ichki NaiveDate.
Sourcepub fn format_as(&self, format: DateFormat) -> String
pub fn format_as(&self, format: DateFormat) -> String
Formatlangan matn.
Trait Implementations§
impl Copy for BirthDate
Source§impl<'de> Deserialize<'de> for BirthDate
Available on crate feature serde only.
impl<'de> Deserialize<'de> for BirthDate
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl<'q, DB: Database> Encode<'q, DB> for BirthDate
impl<'q, DB: Database> Encode<'q, DB> for BirthDate
Source§fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer<'q>, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer<'q>,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
Source§impl<'q, DB: Database> Encode<'q, DB> for BirthDate
impl<'q, DB: Database> Encode<'q, DB> for BirthDate
Source§fn encode_by_ref(
&self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, BoxDynError>
fn encode_by_ref( &self, buf: &mut <DB as Database>::ArgumentBuffer, ) -> Result<IsNull, BoxDynError>
Source§fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
fn encode(
self,
buf: &mut <DB as Database>::ArgumentBuffer,
) -> Result<IsNull, Box<dyn Error + Sync + Send>>where
Self: Sized,
self into buf in the expected format for the database.fn produces(&self) -> Option<<DB as Database>::TypeInfo>
fn size_hint(&self) -> usize
impl Eq for BirthDate
Source§impl Ord for BirthDate
impl Ord for BirthDate
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for BirthDate
impl PartialOrd for BirthDate
Source§impl PgHasArrayType for BirthDatewhere
NaiveDate: PgHasArrayType,
impl PgHasArrayType for BirthDatewhere
NaiveDate: PgHasArrayType,
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
Source§impl PgHasArrayType for BirthDatewhere
NaiveDate: PgHasArrayType,
impl PgHasArrayType for BirthDatewhere
NaiveDate: PgHasArrayType,
fn array_type_info() -> PgTypeInfo
fn array_compatible(ty: &PgTypeInfo) -> bool
impl StructuralPartialEq for BirthDate
Source§impl TryFrom<&str> for BirthDate
impl TryFrom<&str> for BirthDate
Source§type Error = BirthDateError
type Error = BirthDateError
Source§impl TryFrom<NaiveDate> for BirthDate
impl TryFrom<NaiveDate> for BirthDate
Source§type Error = BirthDateError
type Error = BirthDateError
Source§impl TryFrom<String> for BirthDate
impl TryFrom<String> for BirthDate
Source§type Error = BirthDateError
type Error = BirthDateError
Auto Trait Implementations§
impl Freeze for BirthDate
impl RefUnwindSafe for BirthDate
impl Send for BirthDate
impl Sync for BirthDate
impl Unpin for BirthDate
impl UnsafeUnpin for BirthDate
impl UnwindSafe for BirthDate
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more