hotfix_message/encoding/field_types/
tz_timestamp.rs

1use super::{Timestamp, Tz};
2use crate::encoding::{Buffer, FieldType};
3
4/// A time and date combination representing local time with an offset from UTC.
5#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct TzTimestamp {
7    timestamp: Timestamp,
8    tz: Tz,
9}
10
11impl TzTimestamp {
12    /// Returns the [`Timestamp`] (without timezone information) of `self`.
13    pub fn timestamp(&self) -> Timestamp {
14        self.timestamp.clone()
15    }
16
17    /// Returns the [`Tz`] timezone information of `self`.
18    pub fn timezone(&self) -> Tz {
19        self.tz
20    }
21}
22
23impl<'a> FieldType<'a> for TzTimestamp {
24    type Error = &'static str;
25    type SerializeSettings = ();
26
27    fn serialize_with<B>(&self, buffer: &mut B, _settings: ()) -> usize
28    where
29        B: Buffer,
30    {
31        self.timestamp().serialize(buffer)
32    }
33
34    fn deserialize(_data: &'a [u8]) -> Result<Self, Self::Error> {
35        unimplemented!()
36    }
37}