summaryrefslogtreecommitdiff
path: root/src/repo
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-10-01 23:57:22 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-10-01 23:57:22 -0400
commitf878f0b5eaa44e8ee8d67cbfd706926ff2119113 (patch)
treefd9534ebc884da59b4031e2bcf2eb2d9dac35a87 /src/repo
parentd171a258ad2119e39cb715f8800031fff16967dc (diff)
Organize IDs into top-level namespaces.
(This is part of a larger reorganization.)
Diffstat (limited to 'src/repo')
-rw-r--r--src/repo/channel.rs39
-rw-r--r--src/repo/login/mod.rs2
-rw-r--r--src/repo/login/store.rs25
-rw-r--r--src/repo/message.rs28
-rw-r--r--src/repo/token.rs33
5 files changed, 9 insertions, 118 deletions
diff --git a/src/repo/channel.rs b/src/repo/channel.rs
index ad42710..9f1d930 100644
--- a/src/repo/channel.rs
+++ b/src/repo/channel.rs
@@ -1,12 +1,10 @@
-use std::fmt;
-
use sqlx::{sqlite::Sqlite, SqliteConnection, Transaction};
use super::sequence::Sequence;
use crate::{
+ channel::Id,
clock::DateTime,
events::types::{self},
- id::Id as BaseId,
};
pub trait Provider {
@@ -176,38 +174,3 @@ impl<'c> Channels<'c> {
Ok(channels)
}
}
-
-// Stable identifier for a [Channel]. Prefixed with `C`.
-#[derive(
- Clone,
- Debug,
- Eq,
- Hash,
- Ord,
- PartialEq,
- PartialOrd,
- sqlx::Type,
- serde::Deserialize,
- serde::Serialize,
-)]
-#[sqlx(transparent)]
-#[serde(transparent)]
-pub struct Id(BaseId);
-
-impl From<BaseId> for Id {
- fn from(id: BaseId) -> Self {
- Self(id)
- }
-}
-
-impl Id {
- pub fn generate() -> Self {
- BaseId::generate("C")
- }
-}
-
-impl fmt::Display for Id {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- self.0.fmt(f)
- }
-}
diff --git a/src/repo/login/mod.rs b/src/repo/login/mod.rs
index a1b4c6f..4ff7a96 100644
--- a/src/repo/login/mod.rs
+++ b/src/repo/login/mod.rs
@@ -1,4 +1,4 @@
mod extract;
mod store;
-pub use self::store::{Id, Login, Provider};
+pub use self::store::{Login, Provider};
diff --git a/src/repo/login/store.rs b/src/repo/login/store.rs
index b485941..47d1a7c 100644
--- a/src/repo/login/store.rs
+++ b/src/repo/login/store.rs
@@ -1,6 +1,6 @@
use sqlx::{sqlite::Sqlite, SqliteConnection, Transaction};
-use crate::{id::Id as BaseId, password::StoredHash};
+use crate::{login::Id, password::StoredHash};
pub trait Provider {
fn logins(&mut self) -> Logins;
@@ -61,26 +61,3 @@ impl<'t> From<&'t mut SqliteConnection> for Logins<'t> {
Self(tx)
}
}
-
-// Stable identifier for a [Login]. Prefixed with `L`.
-#[derive(Clone, Debug, Eq, PartialEq, sqlx::Type, serde::Serialize)]
-#[sqlx(transparent)]
-pub struct Id(BaseId);
-
-impl From<BaseId> for Id {
- fn from(id: BaseId) -> Self {
- Self(id)
- }
-}
-
-impl Id {
- pub fn generate() -> Self {
- BaseId::generate("L")
- }
-}
-
-impl std::fmt::Display for Id {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- self.0.fmt(f)
- }
-}
diff --git a/src/repo/message.rs b/src/repo/message.rs
index a1f73d5..acde3ea 100644
--- a/src/repo/message.rs
+++ b/src/repo/message.rs
@@ -1,30 +1,4 @@
-use std::fmt;
-
-use crate::id::Id as BaseId;
-
-// Stable identifier for a [Message]. Prefixed with `M`.
-#[derive(Clone, Debug, Eq, Hash, PartialEq, sqlx::Type, serde::Deserialize, serde::Serialize)]
-#[sqlx(transparent)]
-#[serde(transparent)]
-pub struct Id(BaseId);
-
-impl From<BaseId> for Id {
- fn from(id: BaseId) -> Self {
- Self(id)
- }
-}
-
-impl Id {
- pub fn generate() -> Self {
- BaseId::generate("M")
- }
-}
-
-impl fmt::Display for Id {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- self.0.fmt(f)
- }
-}
+use crate::message::Id;
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize)]
pub struct Message {
diff --git a/src/repo/token.rs b/src/repo/token.rs
index 1663f5e..79e5c54 100644
--- a/src/repo/token.rs
+++ b/src/repo/token.rs
@@ -1,10 +1,11 @@
-use std::fmt;
-
use sqlx::{sqlite::Sqlite, SqliteConnection, Transaction};
use uuid::Uuid;
-use super::login::{self, Login};
-use crate::{clock::DateTime, id::Id as BaseId, login::extract::IdentitySecret};
+use super::login::Login;
+use crate::{
+ clock::DateTime,
+ login::{self, extract::IdentitySecret, token::Id},
+};
pub trait Provider {
fn tokens(&mut self) -> Tokens;
@@ -148,27 +149,3 @@ impl<'c> Tokens<'c> {
Ok(login)
}
}
-
-// Stable identifier for a token. Prefixed with `T`.
-#[derive(Clone, Debug, Eq, Hash, PartialEq, sqlx::Type, serde::Deserialize, serde::Serialize)]
-#[sqlx(transparent)]
-#[serde(transparent)]
-pub struct Id(BaseId);
-
-impl From<BaseId> for Id {
- fn from(id: BaseId) -> Self {
- Self(id)
- }
-}
-
-impl Id {
- pub fn generate() -> Self {
- BaseId::generate("T")
- }
-}
-
-impl fmt::Display for Id {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- self.0.fmt(f)
- }
-}