Skip to content
Clone
d5939db
28 lines 662 B Rust
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ActorContext {
pub user_id: Uuid,
pub space_id: Uuid,
pub project_id: Option<Uuid>,
}
impl ActorContext {
pub fn new(user_id: Uuid, space_id: Uuid) -> Self {
Self {
user_id,
space_id,
project_id: None,
}
}
pub fn with_project(mut self, project_id: Uuid) -> Self {
self.project_id = Some(project_id);
self
}
pub fn require_project(&self) -> Result<Uuid, &'static str> {
self.project_id.ok_or("project_id missing in actor context")
}
}