shifty-backend/service/src/lib.rs
Simon Goller 926ac006e7 Return the username in a separate service
This allows us to use a service implementation which
returns a dummy user during development and the actual authenticated
user during production.  It also simplifies tests.
2024-04-26 22:41:44 +02:00

26 lines
634 B
Rust

use std::{future::Future, sync::Arc};
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ServiceError {
#[error("Database query error: {0}")]
DatabaseQueryError(#[from] dao::DaoError),
#[error("Forbidden")]
Forbidden,
}
pub trait HelloService {
fn hello(&self) -> impl Future<Output = Result<Arc<str>, ServiceError>> + Send;
}
pub trait PermissionService {
fn check_permission(
&self,
privilege: &str,
) -> impl Future<Output = Result<(), ServiceError>> + Send;
}
pub trait UserService {
fn current_user(&self) -> impl Future<Output = Result<Arc<str>, ServiceError>> + Send;
}