pub trait DomainPolicy<E: Send + Sync + 'static>: Send + Sync {
// Provided methods
fn can_create<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn can_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_current: &'life1 E,
_updated: &'life2 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn can_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn can_restore<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn enforce_create<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn enforce_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = Result<(), String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Core domain policy trait — governs whether CRUD operations are valid
for a given entity E based on entity state alone (no auth context).
All methods default to Ok(true) (permit). Override only the methods
relevant to the entity’s domain invariants.
Provided Methods§
Sourcefn can_create<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn can_create<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Can a new entity in the given state be persisted?
Sourcefn can_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_current: &'life1 E,
_updated: &'life2 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn can_update<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_current: &'life1 E,
_updated: &'life2 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Can the entity transition from current to updated state?
Sourcefn can_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn can_delete<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Can the entity be soft-deleted?
Sourcefn can_restore<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn can_restore<'life0, 'life1, 'async_trait>(
&'life0 self,
_entity: &'life1 E,
) -> Pin<Box<dyn Future<Output = PolicyDecision> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Can a soft-deleted entity be restored?
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".