Skip to content
Clone

feat(project): add project actor helpers

zhenyi committed
parent 75a6f4c commit 7a4c01f Browse files

1 file changed

+28 −0

Added lib/project/actor.rs View lib/project/actor.rs
@@ -0,0 +1,28 @@
1use serde::{Deserialize, Serialize};
2use uuid::Uuid;
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct ActorContext {
6 pub user_id: Uuid,
7 pub space_id: Uuid,
8 pub project_id: Option<Uuid>,
9}
10
11impl ActorContext {
12 pub fn new(user_id: Uuid, space_id: Uuid) -> Self {
13 Self {
14 user_id,
15 space_id,
16 project_id: None,
17 }
18 }
19
20 pub fn with_project(mut self, project_id: Uuid) -> Self {
21 self.project_id = Some(project_id);
22 self
23 }
24
25 pub fn require_project(&self) -> Result<Uuid, &'static str> {
26 self.project_id.ok_or("project_id missing in actor context")
27 }
28}