pub struct KeepsakeResolver<S, M = TenantScopedSubjectMapper> { /* private fields */ }Expand description
Resolves gatekeep facts from active keepsake relations for the principal.
Implementations§
Source§impl<S> KeepsakeResolver<S, TenantScopedSubjectMapper>
impl<S> KeepsakeResolver<S, TenantScopedSubjectMapper>
Source§impl<S, M> KeepsakeResolver<S, M>
impl<S, M> KeepsakeResolver<S, M>
Sourcepub const fn with_subject_mapper(source: S, subject_mapper: M) -> Self
pub const fn with_subject_mapper(source: S, subject_mapper: M) -> Self
Builds a resolver with an explicit subject mapper.
Sourcepub fn map_subjects<Next>(
self,
subject_mapper: Next,
) -> KeepsakeResolver<S, Next>
pub fn map_subjects<Next>( self, subject_mapper: Next, ) -> KeepsakeResolver<S, Next>
Replaces the subject mapper.
Sourcepub fn with_binding(self, binding: FactBinding) -> Self
pub fn with_binding(self, binding: FactBinding) -> Self
Adds or replaces a fact binding.
Sourcepub fn insert_binding(&mut self, binding: FactBinding)
pub fn insert_binding(&mut self, binding: FactBinding)
Adds or replaces a fact binding.
Sourcepub fn with_relation_spec<F, R>(self) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
pub fn with_relation_spec<F, R>(self) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
Adds or replaces a typed fact-to-relation binding.
§Errors
Returns FactBindingError::Gatekeep if the fact marker exposes an
invalid stable id.
Sourcepub fn with_resolved_relation<F, R>(self) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
pub fn with_resolved_relation<F, R>(self) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
Adds or replaces a typed binding that is resolved during query preparation.
§Errors
Returns FactBindingError::Gatekeep if the fact marker exposes an
invalid stable id.
Sourcepub fn with_deferred_relation<F, R>(self) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
pub fn with_deferred_relation<F, R>(self) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
Adds or replaces a typed binding that is deferred during query preparation for row-level lowering.
§Errors
Returns FactBindingError::Gatekeep if the fact marker exposes an
invalid stable id.
Sourcepub fn with_relation_spec_query_presence<F, R>(
self,
query_presence: QueryPresence,
) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
pub fn with_relation_spec_query_presence<F, R>(
self,
query_presence: QueryPresence,
) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
Adds or replaces a typed binding with explicit query-mode behavior.
§Errors
Returns FactBindingError::Gatekeep if the fact marker exposes an
invalid stable id.
Sourcepub fn with_relation_spec_on_subject<F, R>(
self,
subject_slot: SubjectSlot,
) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
pub fn with_relation_spec_on_subject<F, R>(
self,
subject_slot: SubjectSlot,
) -> Result<Self, FactBindingError>where
F: Fact,
R: RelationSpec,
Adds or replaces a typed binding resolved against a request-scoped subject slot.
§Errors
Returns FactBindingError::Gatekeep if the fact marker exposes an
invalid stable id.
Sourcepub const fn bindings(&self) -> &BTreeMap<FactId, FactBinding>
pub const fn bindings(&self) -> &BTreeMap<FactId, FactBinding>
Returns the configured bindings keyed by fact id.
Sourcepub const fn subject_mapper(&self) -> &M
pub const fn subject_mapper(&self) -> &M
Returns the subject mapper.
Source§impl<S, M> KeepsakeResolver<S, M>where
M: SubjectMapper,
impl<S, M> KeepsakeResolver<S, M>where
M: SubjectMapper,
Sourcepub fn target_for_binding(
&self,
binding: &FactBinding,
cx: &Context,
) -> Result<KeepsakeRelationTarget, KeepsakeTargetError>
pub fn target_for_binding( &self, binding: &FactBinding, cx: &Context, ) -> Result<KeepsakeRelationTarget, KeepsakeTargetError>
Resolves one binding into the keepsake subject/relation target used for lookups.
§Errors
Returns KeepsakeTargetError::MissingSubjectSlot when the binding
targets a request-scoped subject absent from the context, or
KeepsakeTargetError::Subject when keepsake rejects the mapped subject.
Sourcepub fn target_for_fact(
&self,
fact: &FactId,
cx: &Context,
) -> Result<KeepsakeRelationTarget, KeepsakeTargetError>
pub fn target_for_fact( &self, fact: &FactId, cx: &Context, ) -> Result<KeepsakeRelationTarget, KeepsakeTargetError>
Resolves a configured fact id into its keepsake subject/relation target.
§Errors
Returns KeepsakeTargetError::MissingBinding when the fact has no
configured binding. Also returns the subject-resolution errors documented
by Self::target_for_binding.
Sourcepub fn targets_for_facts(
&self,
facts: &[FactId],
cx: &Context,
) -> Result<Vec<KeepsakeRelationTarget>, KeepsakeTargetError>
pub fn targets_for_facts( &self, facts: &[FactId], cx: &Context, ) -> Result<Vec<KeepsakeRelationTarget>, KeepsakeTargetError>
Resolves configured fact ids into keepsake subject/relation targets.
§Errors
Returns the first KeepsakeTargetError encountered while resolving the
requested facts.
Trait Implementations§
Source§impl<S: Clone, M: Clone> Clone for KeepsakeResolver<S, M>
impl<S: Clone, M: Clone> Clone for KeepsakeResolver<S, M>
Source§fn clone(&self) -> KeepsakeResolver<S, M>
fn clone(&self) -> KeepsakeResolver<S, M>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more