aranya_runtime::engine

Trait Policy

Source
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>;
}
Expand description

Policy evaluates actions and Commands on the graph, emitting effects as a result.

Required Associated Types§

Required Methods§

Source

fn serial(&self) -> u32

Policies have a serial number which can be used to order them. This is used to support inband policy upgrades.

Source

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.

Source

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.

Source

fn merge<'a>( &self, target: &'a mut [u8], ids: MergeIds, ) -> Result<Self::Command<'a>, EngineError>

Produces a merge message serialized to target. The struct representing the Command is returned.

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.

Implementors§