From d9375b82c3bb3a917e1795be4dcd7ed849b32ca2 Mon Sep 17 00:00:00 2001 From: rtkay123 Date: Sun, 12 Apr 2026 14:17:49 +0200 Subject: build: migrations --- crates/users/Cargo.toml | 3 +++ crates/users/src/error.rs | 13 +++++++++++++ crates/users/src/lib.rs | 17 ++++++----------- 3 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 crates/users/src/error.rs (limited to 'crates/users') diff --git a/crates/users/Cargo.toml b/crates/users/Cargo.toml index e21ca6c..4c0098e 100644 --- a/crates/users/Cargo.toml +++ b/crates/users/Cargo.toml @@ -8,3 +8,6 @@ documentation.workspace = true homepage.workspace = true [dependencies] +api-core = { workspace = true, features = ["users"] } +async-trait.workspace = true +thiserror.workspace = true diff --git a/crates/users/src/error.rs b/crates/users/src/error.rs new file mode 100644 index 0000000..1ff28ee --- /dev/null +++ b/crates/users/src/error.rs @@ -0,0 +1,13 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum UserError { + #[error("data store disconnected")] + Disconnect(#[from] std::io::Error), + #[error("the data for key `{0}` is not available")] + Redaction(String), + #[error("invalid header (expected {expected:?}, found {found:?})")] + InvalidHeader { expected: String, found: String }, + #[error("unknown data store error")] + Unknown, +} diff --git a/crates/users/src/lib.rs b/crates/users/src/lib.rs index b93cf3f..9a268e7 100644 --- a/crates/users/src/lib.rs +++ b/crates/users/src/lib.rs @@ -1,14 +1,9 @@ -pub fn add(left: u64, right: u64) -> u64 { - left + right -} +pub mod error; +use api_core::models::user::User; -#[cfg(test)] -mod tests { - use super::*; +use crate::error::UserError; - #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); - } +#[async_trait::async_trait] +pub trait UsersDriver: Send + Sync { + async fn get_user_by_email(&self, email: &str) -> Result, UserError>; } -- cgit v1.2.3