Initial commit

This commit is contained in:
Simon Goller 2024-04-26 21:34:00 +02:00
commit dccfa2d4cf
19 changed files with 3156 additions and 0 deletions

12
service/Cargo.toml Normal file
View file

@ -0,0 +1,12 @@
[package]
name = "service"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies.thiserror]
version = "1.0"
[dependencies.dao]
path = "../dao"

24
service/src/lib.rs Normal file
View file

@ -0,0 +1,24 @@
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;
fn current_user(&self) -> impl Future<Output = Result<Arc<str>, ServiceError>> + Send;
}