pub enum Datum {
Boolean(bool),
Number(Decimal),
Date(NaiveDate),
Time(NaiveTime),
DateTime(NaiveDateTime),
String(String),
}Expand description
Value for a field in an ADIF record.
ADIF fields can have various types specified in their tags. If no type is specified, they default to strings. This enum represents all possible typed values, and provides methods to coerce between types.
Variants§
Boolean(bool)
Boolean value (type indicator b in ADIF tags).
Number(Decimal)
Numeric value (type indicator n in ADIF tags).
Date(NaiveDate)
Date value (type indicator d in ADIF tags), format YYYYMMDD.
Time(NaiveTime)
Time value (type indicator t in ADIF tags), format HHMMSS.
DateTime(NaiveDateTime)
Combined date and time value.
This type is not part of the ADIF specification, but it provided as a convenience, e.g. for output by a data normalizer that could combine date and time into a single field.
This type can be output via the output module provided that the writer is configured to not output a type indicator for the datetime field. Attempting to output a datetime with a type indicator will return an error.
String(String)
String value (default when no type indicator is present).
Implementations§
Source§impl Datum
impl Datum
Sourcepub fn as_datetime(&self) -> Option<NaiveDateTime>
pub fn as_datetime(&self) -> Option<NaiveDateTime>
Return a datetime value as a NaiveDateTime or coerce a string thereto.
Returns None if a string value fails to parse.
Sourcepub fn as_str(&self) -> Cow<'_, str>
pub fn as_str(&self) -> Cow<'_, str>
Coerce any datum to a string representation.
String variants return borrowed data. All other types are returned in ADIF format (boolean Y/N, date YYYYMMDD, time HHMMSS).
Sourcepub fn to_cabrillo(&self) -> Cow<'_, str>
pub fn to_cabrillo(&self) -> Cow<'_, str>
Coerce any datum to Cabrillo format string representation.
Trait Implementations§
Source§impl From<NaiveDateTime> for Datum
impl From<NaiveDateTime> for Datum
Source§fn from(value: NaiveDateTime) -> Self
fn from(value: NaiveDateTime) -> Self
impl Eq for Datum
impl StructuralPartialEq for Datum
Auto Trait Implementations§
impl Freeze for Datum
impl RefUnwindSafe for Datum
impl Send for Datum
impl Sync for Datum
impl Unpin for Datum
impl UnwindSafe for Datum
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.