aboutsummaryrefslogtreecommitdiff
path: root/src/primitive/msgid.rs
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2025-02-26 17:20:15 +0100
committerMax Audron <audron@cocaine.farm>2025-02-26 17:20:15 +0100
commitbb861cb828dedaae880d1f0cea759d79020f6c90 (patch)
tree0ac14b0a4ac2c4d0798621f7182fec5d435c1be0 /src/primitive/msgid.rs
parentenable transparent repr for msgid and bufferid (diff)
add MsgId and BufferId to objects where needed
some objects where still handling BufferId or MsgId as their raw types which lead to errors now that the Types are properly parsed in the varinats
Diffstat (limited to 'src/primitive/msgid.rs')
-rw-r--r--src/primitive/msgid.rs27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/primitive/msgid.rs b/src/primitive/msgid.rs
index fb9b6af..27608fe 100644
--- a/src/primitive/msgid.rs
+++ b/src/primitive/msgid.rs
@@ -1,4 +1,4 @@
-#[derive(Copy, Clone, Debug, std::cmp::PartialEq)]
+#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct MsgId(
#[cfg(not(feature = "long-message-id"))] pub i32,
@@ -24,6 +24,31 @@ impl Deserialize for MsgId {
}
}
+#[cfg(not(feature = "long-message-id"))]
+impl From<i32> for MsgId {
+ fn from(value: i32) -> Self {
+ Self(value)
+ }
+}
+
+#[cfg(feature = "long-message-id")]
+impl From<i64> for MsgId {
+ fn from(value: i64) -> Self {
+ Self(value)
+ }
+}
+
+impl std::ops::Deref for MsgId {
+ #[cfg(not(feature = "long-message-id"))]
+ type Target = i32;
+ #[cfg(feature = "long-message-id")]
+ type Target = i64;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
25-02-26implement IdentityIdMax Audron-8/+79 2025-02-26refactor variant deserializationMax Audron-123/+59 2025-02-26refactor deserialize and serializevariant traitMax Audron-90/+80 2025-02-26refactor variant serialization codeMax Audron-256/+405 2025-02-26add MsgId and BufferId to objects where neededMax Audron-141/+157 2025-02-25enable transparent repr for msgid and bufferidMax Audron-0/+2 2025-02-25Implement BacklogManagerTobias Deiminger-59/+113 2025-02-25Use BufferId in BufferInfoTobias Deiminger-10/+11 2025-02-25Use BufferId in VariantTobias Deiminger-2/+33 2025-02-25Add BufferId as Rust typeTobias Deiminger-0/+39 2025-02-25Use MsgId in MessageTobias Deiminger-18/+6 2025-02-25Use MsgId in VariantTobias Deiminger-20/+37 2025-02-25Add MsgId as Rust typeTobias Deiminger-0/+56 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 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