pub struct Tz { /* private fields */ }
Expand description
Timezone indicator.
§Examples
use hotfix_encoding::field_access::FieldType;
use hotfix_encoding::field_types::Tz;
use std::time::Duration;
let timezone = Tz::deserialize(b"Z").unwrap();
assert_eq!(timezone, Tz::UTC);
assert_eq!(timezone.offset().1, Duration::from_secs(0));
let timezone = Tz::deserialize(b"+03").unwrap();
assert_eq!(timezone.offset(), (1, Duration::from_secs(3 * 3600)));
let timezone = Tz::deserialize(b"-01").unwrap();
assert_eq!(timezone.offset(), (-1, Duration::from_secs(1 * 3600)));
let timezone = Tz::deserialize(b"+04:30").unwrap();
assert_eq!(timezone.offset(), (1, Duration::from_secs(4 * 3600 + 30 * 60)));
Implementations§
Trait Implementations§
Source§impl<'a> FieldType<'a> for Tz
impl<'a> FieldType<'a> for Tz
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 Tz
impl Eq for Tz
impl StructuralPartialEq for Tz
Auto Trait Implementations§
impl Freeze for Tz
impl RefUnwindSafe for Tz
impl Send for Tz
impl Sync for Tz
impl Unpin for Tz
impl UnwindSafe for Tz
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