aboutsummaryrefslogtreecommitdiffstats
path: root/crates/users/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/users/src')
-rw-r--r--crates/users/src/error.rs13
-rw-r--r--crates/users/src/lib.rs17
2 files changed, 19 insertions, 11 deletions
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>;
}