Trait Directive

Source
pub trait Directive<Discriminant: DiscriminantTag = ()>: Sized {
    // Required methods
    fn precision(&self) -> Precision;
    fn fortitude(&self) -> Fortitude;
    fn new(precision: Precision, fortitude: Fortitude) -> Self;
}
Expand description

A trait expressing the execution directive of an operation.

Directive defines how an action should be carried out, independent of the value or state it operates on. It captures two orthogonal dimensions:

  • [Precision]: The required exactness of the operation.

    • Exact: The operation must satisfy strict conditions.
    • BestEffort: The operation may proceed with relaxed or partial fulfillment.
  • [Fortitude]: The strength or authority of execution.

    • Polite: The operation should respect constraints and may yield.
    • Force: The operation must be enforced regardless of resistance.

§Interpretation

PrecisionFortitudeMeaning
BestEffortPoliteSoft, optional attempt
ExactPoliteStrict but non-forcing
BestEffortForceEnforced but flexible execution
ExactForceStrict and mandatory execution

§Design Notes

  • Encodes intent, not state or value
  • Fully domain-agnostic
  • Separates what to do from how to do it
  • Enables consistent execution behavior across systems

Implementations should ensure that from_directive produces a value whose behavior reflects the specified execution semantics.

§Default Discriminant

  • Discriminant = (): defines a single default directive, meaning one unique set of directions is assumed.

Required Methods§

Source

fn precision(&self) -> Precision

Returns the required precision of the operation.

Source

fn fortitude(&self) -> Fortitude

Returns the enforcement strength of the operation.

Source

fn new(precision: Precision, fortitude: Fortitude) -> Self

Constructs a value from execution semantics.

The resulting value should embody how the operation behaves in terms of strictness and enforcement.

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§