mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-19 08:41:24 +01:00
Add wrapper types for short IDs
This commit is contained in:
parent
f1642c92d1
commit
b0f33207fe
28 changed files with 427 additions and 232 deletions
|
|
@ -1,4 +1,27 @@
|
|||
mod data;
|
||||
|
||||
macro_rules! short_id_type {
|
||||
($name:ident) => {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[repr(transparent)]
|
||||
pub(crate) struct $name(u64);
|
||||
|
||||
impl $name {
|
||||
pub(crate) fn new(id: u64) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
|
||||
pub(crate) fn get(&self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
short_id_type!(ShortRoomId);
|
||||
short_id_type!(ShortEventId);
|
||||
short_id_type!(ShortStateHash);
|
||||
short_id_type!(ShortStateKey);
|
||||
|
||||
pub(crate) use data::Data;
|
||||
pub(crate) type Service = &'static dyn Data;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue