Skip to main content

Engine

Trait Engine 

Source
pub trait Engine {
    // Required methods
    fn load(&mut self, setup: &Setup) -> Result<(), Refusal>;
    fn apply(&mut self, event: &Event) -> Result<(), Refusal>;
    fn query(&self, q: &Query) -> Result<Value, Refusal>;
    fn claims(&self) -> Claims;
    fn change(&mut self, change: &ChangeSpec) -> Result<(), Refusal>;
}
Expand description

An accounting engine, as bookspec checks it.

The four methods are the plan’s (plan/served.md 8.2 P13 step 2); the fifth, Engine::change, is the one departure: an example’s [[changes]] (a rename, the tax-category policy, an asset correction) posts no entry, so it is neither a setup nor an event, and the plan’s four methods have no path for it. It is required, never defaulted, so an engine cannot silently skip the examples that use one.

Required Methods§

Source

fn load(&mut self, setup: &Setup) -> Result<(), Refusal>

Set the books up: the chart, the fixed assets, the schedules, the parties, the members, the payees and their dated decisions, the payment methods and the projects.

Source

fn apply(&mut self, event: &Event) -> Result<(), Refusal>

Apply one event: an entry, a reversal, a close, a bill, an invoice, a depreciation run, a disposal, a schedules run or a schedule’s registration. An event the engine refuses leaves the books as they were.

Source

fn query(&self, q: &Query) -> Result<Value, Refusal>

Answer one query with the engine’s own figures. A figure is an exact decimal string (never a JSON number: no engine may round a cent through a float), a date is YYYY-MM-DD, and a format query’s value is its lines or rows. A query the engine refuses (a period the rule refuses, a command it refuses) is an Err.

Source

fn claims(&self) -> Claims

The rules and choices this engine declares.

Source

fn change(&mut self, change: &ChangeSpec) -> Result<(), Refusal>

Apply one change that posts no entry (a [[changes]] entry).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§