diff options
| author | rtkay123 <dev@kanjala.com> | 2026-04-12 14:17:49 +0200 |
|---|---|---|
| committer | rtkay123 <dev@kanjala.com> | 2026-04-12 14:17:49 +0200 |
| commit | d9375b82c3bb3a917e1795be4dcd7ed849b32ca2 (patch) | |
| tree | 308245b0e578179bf0ff047ddc453ab1934a0795 /crates/users | |
| parent | 34b2f8ff6a99471fbb72ed7c52a92b92645b0652 (diff) | |
| download | sellershut-d9375b82c3bb3a917e1795be4dcd7ed849b32ca2.tar.bz2 sellershut-d9375b82c3bb3a917e1795be4dcd7ed849b32ca2.zip | |
build: migrations
Diffstat (limited to 'crates/users')
| -rw-r--r-- | crates/users/Cargo.toml | 3 | ||||
| -rw-r--r-- | crates/users/src/error.rs | 13 | ||||
| -rw-r--r-- | crates/users/src/lib.rs | 17 |
3 files changed, 22 insertions, 11 deletions
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<Option<User>, UserError>; } |
