Skip to main content

gatekeep_keepsake/
target.rs

1use chrono::{DateTime, Utc};
2use gatekeep::{FactId, SubjectSlot};
3use keepsake::{CommandContext, RelationId, RevokeBySubject, SubjectRef};
4
5/// Resolved keepsake target for a gatekeep fact binding.
6#[derive(Clone, Debug, PartialEq, Eq)]
7pub struct KeepsakeRelationTarget {
8    /// Gatekeep fact that maps to this keepsake relation target.
9    pub fact: FactId,
10    /// Keepsake subject used for relation lookups and lifecycle writes.
11    pub subject: SubjectRef,
12    /// Keepsake relation definition id.
13    pub relation_id: RelationId,
14    /// Request-scoped subject slot used by this target, when any.
15    pub subject_slot: Option<SubjectSlot>,
16}
17
18impl KeepsakeRelationTarget {
19    /// Builds a keepsake revoke-by-subject command for this target.
20    #[must_use]
21    pub fn revoke_by_subject(&self, at: DateTime<Utc>, context: CommandContext) -> RevokeBySubject {
22        RevokeBySubject::new(self.subject.clone(), self.relation_id, at, context)
23    }
24}