aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/primitive/datetime.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/protocol/primitive/datetime.rs93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/protocol/primitive/datetime.rs b/src/protocol/primitive/datetime.rs
new file mode 100644
index 0000000..688a022
--- /dev/null
+++ b/src/protocol/primitive/datetime.rs
@@ -0,0 +1,93 @@
+use crate::protocol::primitive::deserialize::Deserialize;
+use crate::protocol::primitive::serialize::Serialize;
+
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct DateTime {
+ julian_day: i32, // Day in Julian calendar, unknown if signed or unsigned
+ millis_of_day: i32, // Milliseconds since start of day
+ zone: u8, // Timezone of DateTime, 0x00 is local, 0x01 is UTC
+}
+
+impl Serialize for DateTime {
+ fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> {
+ let mut values: Vec<u8> = Vec::new();
+
+ values.append(&mut i32::serialize(&self.julian_day)?);
+ values.append(&mut i32::serialize(&self.millis_of_day)?);
+ values.append(&mut u8::serialize(&(self.zone))?);
+
+ Ok(values)
+ }
+}
+
+impl Deserialize for DateTime {
+ fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error>
+ where
+ Self: Sized,
+ {
+ let (_, julian_day) = i32::parse(&b[0..4])?;
+ let (_, millis_of_day) = i32::parse(&b[4..8])?;
+ let (_, zone) = u8::parse(&b[8..9])?;
+
+ return Ok((
+ 9,
+ DateTime {
+ julian_day,
+ millis_of_day,
+ zone,
+ },
+ ));
+ }
+}
+
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct Date {
+ julian_day: i32, // Day in Julian calendar, unknown if signed or unsigned
+}
+
+impl Serialize for Date {
+ fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> {
+ let mut values: Vec<u8> = Vec::new();
+
+ values.append(&mut i32::serialize(&self.julian_day)?);
+
+ Ok(values)
+ }
+}
+
+impl Deserialize for Date {
+ fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error>
+ where
+ Self: Sized,
+ {
+ let (_, julian_day) = i32::parse(&b[0..4])?;
+
+ return Ok((9, Date { julian_day }));
+ }
+}
+
+#[derive(Clone, Debug, std::cmp::PartialEq)]
+pub struct Time {
+ millis_of_day: i32, // Milliseconds since start of day
+}
+
+impl Serialize for Time {
+ fn serialize(&self) -> Result<Vec<std::primitive::u8>, failure::Error> {
+ let mut values: Vec<u8> = Vec::new();
+
+ values.append(&mut i32::serialize(&self.millis_of_day)?);
+
+ Ok(values)
+ }
+}
+
+impl Deserialize for Time {
+ fn parse(b: &[std::primitive::u8]) -> Result<(std::primitive::usize, Self), failure::Error>
+ where
+ Self: Sized,
+ {
+ let (_, millis_of_day) = i32::parse(&b[0..4])?;
+
+ return Ok((4, Time { millis_of_day }));
+ }
+}
s?id=5b8929435cb955169d7d497fc8d759e50d5f67ff&follow=1'>setup mailserverMax Audron-27/+213 2025-09-20replace dns bgp anouncementMax Audron-2/+2 2025-09-15update flaresolverrMax Audron-1/+1 2025-09-07add audron windows wg keyMax Audron-0/+8 2025-09-02switch out vultr dns ipv4 ipMax Audron-1/+5 2025-08-11disable homepage trackersMax Audron-3/+3 2025-08-11add mail serverMax Audron-1/+245 2025-08-05add prometheus alerting rulesMax Audron-38/+144 2025-08-01add homepage dashboardMax Audron-3/+284 2025-08-01disable not used gameserversMax Audron-1/+2 2025-08-01add minecraft prometheus exporterMax Audron-3/+67 2025-08-01more monitoring & scrape config shortcutsMax Audron-68/+63 2025-08-01update garage to 2.0Max Audron-6/+10 2025-07-31fix authentik-ldap port bindingsMax Audron-0/+5 2025-07-31update to nixos 25.05Max Audron-113/+65 2025-07-31add more monitoring exporters and scrapersMax Audron-17/+57 2025-07-30try to run authentik nativelyMax Audron-26/+303 2025-07-30more metricsMax Audron-1/+41 2025-07-30enable firewallsMax Audron-1/+39 rc/primitive/msgid.rs?h=master&id=522258c809c9617bd6d92ee7305225a08803b369&follow=1'>Add MsgId as Rust typeTobias Deiminger-0/+56 Up to now it was handled implicitely in Variant::UserType. Making it an explicit type allows to centralize the i32/i64 cfg dependency and to use the type for arguments in signalproxy::objects functions. 2025-02-24added session manager comments and log messageMax Audron-1/+3 2025-02-23add identity syncable to SessionManagerMax Audron-1/+8 2025-02-23add syncables for IrcUserMax Audron-2/+53 2025-02-23move network config to it's own file and impl it's syncMax Audron-23/+84 2025-02-23add basic network syncablesMax Audron-39/+420 2025-02-23clean up unused_import and unused_variables a bitMax Audron-2/+8 2025-02-23fix server feature errorsMax Audron-28/+23 2025-02-23fix ircchannel and maplist network representationMax Audron-154/+137 2025-02-22replace deprecated failure crate with thiserrorMax Audron-278/+194 this changes the public API in that all our methods now return a proper ProtocolError crate. Needed change anyways to properly deal with all our errors in the long run. Will still need to do a pass through the crate to remove all existing unwraps where it makes sense. 2025-02-22update dependencies and fix errorsMax Audron-508/+332 2025-02-22update flakeMax Audron-94/+117 2024-05-22add todos to readmeMax Audron-16/+35