Skip to main content

Calc

Struct Calc 

Source
pub struct Calc<'m> { /* private fields */ }
Expand description

One recalculation of one model under one library: the plan made once, the cells evaluated in order, by steps or all at once.

Implementations§

Source§

impl<'m> Calc<'m>

Source

pub fn new(model: &'m Workbook, library: &'m Library) -> Calc<'m>

The plan over the model: every formula cell’s text read off the grid (a shared formula’s child as its master’s text moved), the graph built from refers, the order found and every cycle named. Nothing is evaluated yet.

Source

pub fn run(model: &'m Workbook, library: &'m Library) -> Calc<'m>

The plan made and every cell evaluated.

Source

pub fn model(&self) -> &'m Workbook

The model.

Source

pub fn library(&self) -> &'m Library

The library.

Source

pub fn plan(&self) -> &Plan

The plan: the order and the cycles.

Source

pub fn cycles(&self) -> &[Vec<(usize, u32, u32)>]

Every cycle, each its cells sorted, the cycles by their first cell.

Source

pub fn formulas(&self) -> usize

How many formula cells the model holds.

Source

pub fn formula(&self, id: (usize, u32, u32)) -> Option<&str>

A formula cell’s text without its =, or None for a value cell.

Source

pub fn formula_cells(&self) -> Vec<(usize, u32, u32)>

Every formula cell, in sheet then row-major order.

Source

pub fn computed(&self, id: (usize, u32, u32)) -> Option<&Computed>

What a formula cell holds, once evaluated; None for a value cell or a cell the steps have not reached.

Source

pub fn step(&mut self, budget: usize) -> Progress

Evaluate the next cells of the order, at most budget of them, 0 meaning every one: SD-34’s step, a budget in cells and never in time, so that the frame’s values are the same whatever the host’s chunking. The cells in a cycle count as done from the start.

Source

pub fn progress(&self) -> Progress

Where the evaluation stands.

Source

pub fn restart(&mut self)

Start the order again, every value forgotten but the cycles’.

Source

pub fn missing_functions(&self) -> Vec<((usize, u32, u32), String)>

The functions the formulas call that the library does not hold, with the first cell calling each, in sheet then row-major order: what the engine’s load refuses by name before the first step.

Source

pub fn spell_cell(&self, id: (usize, u32, u32)) -> String

Sheet!A1 for a cell, the sheet quoted as a reference quotes it.

Source

pub fn first_refusal(&self) -> Option<Refusal>

The first thing that stops the whole grid from being stepped, as a refusal from the catalogue: a cycle, naming the cells that close it (calc-cycle), else the first function the library does not hold, naming the cell that calls it (calc-function-not-computed), else the first formula whose text this version does not read, naming the construct (calc-construct-not-read, KERNEL.22: the “unreadable reference” KERNEL.7’s fifth decision named for an engine’s load); None when every formula can be computed. An engine’s load asks this once; frazaro calc never does, since a workbook is read as it is and each cell says what it can.

Trait Implementations§

Source§

impl Debug for Calc<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Env for Calc<'_>

Source§

fn model(&self) -> &Workbook

The model.
Source§

fn here(&self) -> (usize, u32, u32)

The cell being computed.
Source§

fn read(&self, id: (usize, u32, u32)) -> Result<Value, Reason>

A cell’s value now: a constant as it stands, a formula’s computed value, Empty for a cell with nothing; a formula not computed is the reason, which propagates.
Source§

fn extent(&self, sheet: usize) -> Option<((u32, u32), (u32, u32))>

A sheet’s used rectangle, cached by the caller.
Source§

fn name(&self, name: &str, scope: Option<usize>, home: usize) -> Option<&str>

The text of a defined name, resolved as graph::Names::resolve resolves it.
Source§

fn dense(&self, _sheet: usize) -> Option<&Dense>

A sheet’s values kept as an array over its extent, when the environment keeps one (KERNEL.20: an engine’s machine, for each .last twin; and since KERNEL.31 for each of its frame’s own sheets its plan reads by a range or a run’s moving cell, while none of their formulas holds a reason): each slot the value a read of its cell answers, or Value::Empty for a cell holding none, which a walk skips as a walk of the cells skips it; so a range of the sheet is walked by index and never cell by cell. None, a sheet walked through its cells, unless an environment says otherwise.
Source§

fn enter(&self, _id: (usize, u32, u32))

The cell being computed from now on, told by an evaluation of many cells at once before it computes at each (KERNEL.20, super::vector), so that Env::here answers it: an engine’s machine keeps it as it keeps the cell it evaluates alone. Nothing, unless an environment says otherwise.
Source§

impl Values for Calc<'_>

Source§

fn computed(&self, id: (usize, u32, u32)) -> Option<&Computed>

Source§

fn kept_extent(&self, sheet: usize) -> Option<Option<((u32, u32), (u32, u32))>>

A sheet’s extent where the values keep it (KERNEL.37), so that a view reads its extent row without walking every cell of the sheet: the extent itself, Some(None) for a sheet with no cell, or None to have the view walk the sheet. Calc keeps every sheet’s from its making, and an engine’s machine from its load and every write and frame’s end, for the evaluator (Env::extent).
Source§

fn lags(&self, _sheet: usize) -> bool

Whether some of a sheet’s cells hold content newer than the model’s (KERNEL.27): an engine’s machine makes a twin’s cells from its array only when a reader of the twin as a sheet asks, and the record and the plane read such a sheet’s cells through Values::content. No sheet, for any other.
Source§

fn content(&self, _id: (usize, u32, u32)) -> Option<Content>

A cell’s content where it is newer than the model’s, on a sheet that Values::lags; None for the model’s own.

Auto Trait Implementations§

§

impl<'m> !Freeze for Calc<'m>

§

impl<'m> !RefUnwindSafe for Calc<'m>

§

impl<'m> !Sync for Calc<'m>

§

impl<'m> Send for Calc<'m>

§

impl<'m> Unpin for Calc<'m>

§

impl<'m> UnsafeUnpin for Calc<'m>

§

impl<'m> UnwindSafe for Calc<'m>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.