pub trait Policy {
type Action<'a>;
type Effect;
type Command<'a>: Command;
// Required methods
fn serial(&self) -> u32;
fn call_rule(
&self,
command: &impl Command,
facts: &mut impl FactPerspective,
sink: &mut impl Sink<Self::Effect>,
recall: CommandRecall,
) -> Result<(), EngineError>;
fn call_action(
&self,
action: Self::Action<'_>,
facts: &mut impl Perspective,
sink: &mut impl Sink<Self::Effect>,
) -> Result<(), EngineError>;
fn merge<'a>(
&self,
target: &'a mut [u8],
ids: MergeIds,
) -> Result<Self::Command<'a>, EngineError>;
}Required Associated Types§
Required Methods§
Sourcefn serial(&self) -> u32
fn serial(&self) -> u32
Policies have a serial number which can be used to order them. This is used to support inband policy upgrades.
Sourcefn call_rule(
&self,
command: &impl Command,
facts: &mut impl FactPerspective,
sink: &mut impl Sink<Self::Effect>,
recall: CommandRecall,
) -> Result<(), EngineError>
fn call_rule( &self, command: &impl Command, facts: &mut impl FactPerspective, sink: &mut impl Sink<Self::Effect>, recall: CommandRecall, ) -> Result<(), EngineError>
Evaluate a command at the given perspective. If the command is accepted, effects may be emitted to the sink and facts may be written to the perspective. Returns an error for a rejected command.
Sourcefn call_action(
&self,
action: Self::Action<'_>,
facts: &mut impl Perspective,
sink: &mut impl Sink<Self::Effect>,
) -> Result<(), EngineError>
fn call_action( &self, action: Self::Action<'_>, facts: &mut impl Perspective, sink: &mut impl Sink<Self::Effect>, ) -> Result<(), EngineError>
Process an action checking each published command against the policy and emitting effects to the sink. All published commands are handled transactionally where if any published command is rejected no commands are added to the storage.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.