pub struct MonthYear { /* private fields */ }
Expand description
Canonical data field (DTF) for
FixDatatype::MonthYear
.
Implementations§
Source§impl MonthYear
impl MonthYear
Sourcepub fn to_yyyymmww(&self) -> [u8; 8]
pub fn to_yyyymmww(&self) -> [u8; 8]
Converts self
to a byte array.
Sourcepub fn year(&self) -> u32
pub fn year(&self) -> u32
Returns the year of self
.
§Examples
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::MonthYear;
let dtf = MonthYear::deserialize(b"19390901").unwrap();
assert_eq!(dtf.year(), 1939)
Sourcepub fn month(&self) -> u32
pub fn month(&self) -> u32
Returns the month of self
, starting from January as 1.
§Examples
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::MonthYear;
let dtf = MonthYear::deserialize(b"20000101").unwrap();
assert_eq!(dtf.month(), 1)
Sourcepub fn day(&self) -> Option<u32>
pub fn day(&self) -> Option<u32>
Returns the day of self
, if defined.
§Examples
Day included in the definition:
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::MonthYear;
let dtf = MonthYear::deserialize(b"20191225").unwrap();
assert_eq!(dtf.day(), Some(25))
Day not included:
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::MonthYear;
let dtf = MonthYear::deserialize(b"201801w3").unwrap();
assert_eq!(dtf.day(), None)
Sourcepub fn week(&self) -> Option<u32>
pub fn week(&self) -> Option<u32>
Returns the intra-month week code of self
, if defined. Note that it is
1-indexed.
§Examples
Present week code:
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::MonthYear;
let dtf = MonthYear::deserialize(b"201912w1").unwrap();
assert_eq!(dtf.week(), Some(1))
Absent week code:
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::MonthYear;
let dtf = MonthYear::deserialize(b"20191225").unwrap();
assert_eq!(dtf.week(), None)
Trait Implementations§
Source§impl<'a> FieldType<'a> for MonthYear
impl<'a> FieldType<'a> for MonthYear
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 moreimpl Copy for MonthYear
impl Eq for MonthYear
impl StructuralPartialEq for MonthYear
Auto Trait Implementations§
impl Freeze for MonthYear
impl RefUnwindSafe for MonthYear
impl Send for MonthYear
impl Sync for MonthYear
impl Unpin for MonthYear
impl UnwindSafe for MonthYear
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