1
0
Fork 0
forked from 2sys/phonograph
phonograph/phono-models/src/accessors/mod.rs
2025-12-18 20:05:46 +00:00

28 lines
764 B
Rust

use uuid::Uuid;
use crate::errors::AccessError;
pub mod portal;
pub mod workspace;
#[derive(Clone, Copy, Debug, PartialEq, strum::Display, strum::EnumIs)]
pub enum Actor {
/// Bypass explicit auth checks.
Bypass,
#[strum(to_string = "User({0})")]
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>>;
}