2025-11-19 01:31:09 +00:00
|
|
|
use uuid::Uuid;
|
|
|
|
|
|
2025-12-10 22:01:47 +00:00
|
|
|
use crate::errors::AccessError;
|
|
|
|
|
|
2025-11-19 01:31:09 +00:00
|
|
|
pub mod portal;
|
2025-12-10 22:01:47 +00:00
|
|
|
pub mod workspace;
|
2025-11-19 01:31:09 +00:00
|
|
|
|
2025-12-16 09:59:30 -08:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, strum::Display, strum::EnumIs)]
|
2025-11-19 01:31:09 +00:00
|
|
|
pub enum Actor {
|
|
|
|
|
/// Bypass explicit auth checks.
|
|
|
|
|
Bypass,
|
|
|
|
|
|
2025-12-10 22:01:47 +00:00
|
|
|
#[strum(to_string = "User({0})")]
|
2025-11-19 01:31:09 +00:00
|
|
|
User(Uuid),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Provides methods for fetching database entities of type `T`, typically with
|
|
|
|
|
/// authorization checks.
|
|
|
|
|
pub trait Accessor<T>: Default + Sized {
|
|
|
|
|
/// Returns a new builder struct. Alias for [`Self::default()`].
|
|
|
|
|
fn new() -> Self {
|
|
|
|
|
Self::default()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Fetch an entity from the database, returning [`AccessError::NotFound`]
|
|
|
|
|
/// if access is denied or the object cannot be found.
|
|
|
|
|
fn fetch_one(self) -> impl Future<Output = Result<T, AccessError>>;
|
|
|
|
|
}
|