pub struct Date { /* private fields */ }
Expand description
Representation for LocalMktDate
and and UTCDateOnly
in YYYYMMDD
format.
§Examples
19411208
16201211
18630101
20170526
Implementations§
Source§impl Date
impl Date
Sourcepub fn new(year: u32, month: u32, day: u32) -> Option<Self>
pub fn new(year: u32, month: u32, day: u32) -> Option<Self>
Creates a new date from its components. It returns None
if any of the
three components is outside the legal range.
§Examples
use hotfix_encoding::field_types::Date;
assert!(Date::new(2021, 4, 16).is_some());
assert!(Date::new(2021, 13, 32).is_none());
// Support from January 1, year zero (which doesn't actually exist) to
// December 31, 9999.
assert!(Date::new(0, 1, 1).is_some());
assert!(Date::new(9999, 12, 31).is_some());
// We don't check month-aware day boundaries, i.e. go ahead and assume
// every month has 31 days.
assert!(Date::new(2021, 2, 31).is_some());
Sourcepub fn to_yyyymmdd(&self) -> [u8; 8]
pub fn to_yyyymmdd(&self) -> [u8; 8]
Converts self
to YYYYMMDD
format.
§Examples
use hotfix_encoding::field_types::Date;
assert_eq!(&Date::new(2021, 01, 01).unwrap().to_yyyymmdd(), b"20210101");
Trait Implementations§
Source§impl<'a> FieldType<'a> for Date
impl<'a> FieldType<'a> for Date
Source§type SerializeSettings = ()
type SerializeSettings = ()
A type with values that customize the serialization algorithm, e.g.
padding information.
Source§fn serialize_with<B>(&self, buffer: &mut B, _settings: ()) -> usizewhere
B: Buffer,
fn serialize_with<B>(&self, buffer: &mut B, _settings: ()) -> usizewhere
B: Buffer,
Writes
self
to buffer
using custom serialization settings
.Source§fn deserialize(data: &'a [u8]) -> Result<Self, Self::Error>
fn deserialize(data: &'a [u8]) -> Result<Self, Self::Error>
Parses and deserializes from
data
.Source§fn deserialize_lossy(data: &'a [u8]) -> Result<Self, Self::Error>
fn deserialize_lossy(data: &'a [u8]) -> Result<Self, Self::Error>
Like
FieldType::deserialize
, but it’s allowed to skip some amount of
input checking. Invalid inputs might not trigger errors and instead be
deserialized as random values. Read moreSource§impl Ord for Date
impl Ord for Date
Source§impl PartialOrd for Date
impl PartialOrd for Date
impl Copy for Date
impl Eq for Date
impl StructuralPartialEq for Date
Auto Trait Implementations§
impl Freeze for Date
impl RefUnwindSafe for Date
impl Send for Date
impl Sync for Date
impl Unpin for Date
impl UnwindSafe for Date
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
Mutably borrows from an owned value. Read more