From f245389c0223ed96542969dafc90f0aeab1da9f5 Mon Sep 17 00:00:00 2001
From: Jason Volk <jason@zemos.net>
Date: Sat, 26 Oct 2024 22:20:16 +0000
Subject: [PATCH] add typedef for pdu_ids

Signed-off-by: Jason Volk <jason@zemos.net>
---
 src/service/rooms/short/mod.rs      |  4 ++++
 src/service/rooms/timeline/mod.rs   |  6 +++++-
 src/service/rooms/timeline/pduid.rs | 13 +++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)
 create mode 100644 src/service/rooms/timeline/pduid.rs

diff --git a/src/service/rooms/short/mod.rs b/src/service/rooms/short/mod.rs
index 609c0e07..02c449cc 100644
--- a/src/service/rooms/short/mod.rs
+++ b/src/service/rooms/short/mod.rs
@@ -24,6 +24,10 @@ struct Services {
 	globals: Dep<globals::Service>,
 }
 
+pub type ShortEventId = ShortId;
+pub type ShortRoomId = ShortId;
+pub type ShortId = u64;
+
 impl crate::Service for Service {
 	fn build(args: crate::Args<'_>) -> Result<Arc<Self>> {
 		Ok(Arc::new(Self {
diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs
index 902e50ff..e45bf7e5 100644
--- a/src/service/rooms/timeline/mod.rs
+++ b/src/service/rooms/timeline/mod.rs
@@ -1,4 +1,5 @@
 mod data;
+mod pduid;
 
 use std::{
 	cmp,
@@ -38,7 +39,10 @@ use serde::Deserialize;
 use serde_json::value::{to_raw_value, RawValue as RawJsonValue};
 
 use self::data::Data;
-pub use self::data::PdusIterItem;
+pub use self::{
+	data::PdusIterItem,
+	pduid::{PduId, RawPduId},
+};
 use crate::{
 	account_data, admin, appservice, appservice::NamespaceRegex, globals, pusher, rooms,
 	rooms::state_compressor::CompressedStateEvent, sending, server_keys, users, Dep,
diff --git a/src/service/rooms/timeline/pduid.rs b/src/service/rooms/timeline/pduid.rs
new file mode 100644
index 00000000..b43c382c
--- /dev/null
+++ b/src/service/rooms/timeline/pduid.rs
@@ -0,0 +1,13 @@
+use crate::rooms::short::{ShortEventId, ShortRoomId};
+
+#[derive(Clone, Copy)]
+pub struct PduId {
+	_room_id: ShortRoomId,
+	_event_id: ShortEventId,
+}
+
+pub type RawPduId = [u8; PduId::LEN];
+
+impl PduId {
+	pub const LEN: usize = size_of::<ShortRoomId>() + size_of::<ShortEventId>();
+}