Skip to main content

WasmCalculator

Struct WasmCalculator 

Source
pub struct WasmCalculator { /* private fields */ }
Expand description

WASM Calculator - browser-ready calculator

Implementations§

Source§

impl WasmCalculator

Source

pub fn new() -> Self

Creates a new WASM calculator

Source

pub fn with_validator(validator: AnomalyValidator) -> Self

Creates a calculator with custom Anomaly validator

Source

pub fn set_input(&mut self, expr: &str)

Sets the input expression

Source

pub fn input(&self) -> &str

Gets the current input

Source

pub fn append_input(&mut self, s: &str)

Appends to the input

Source

pub fn backspace(&mut self)

Removes the last character from input

Source

pub fn clear(&mut self)

Clears all state

Source

pub fn clear_input(&mut self)

Clears only the input (keeps result)

Source

pub fn evaluate(&mut self) -> CalcResult<f64>

Evaluates the current input expression

Source

pub fn result(&self) -> Option<&Result<f64, CalcError>>

Gets the last result

Source

pub fn result_display(&self) -> String

Gets a formatted result display string

Source

pub fn history(&self) -> &History

Gets the calculation history

Source

pub fn history_entries(&self) -> Vec<String>

Gets history as JSON-like string array (for WASM interop)

Source

pub fn history_entries_rev(&self) -> Vec<String>

Gets history entries in reverse order (newest first)

Source

pub fn jidoka_status(&self) -> &[String]

Gets the Anomaly status messages

Source

pub fn clear_history(&mut self)

Clears the history

Source

pub fn history_len(&self) -> usize

Gets the number of history entries

Source

pub fn recall_history(&self, index: usize) -> Option<&HistoryEntry>

Recalls a history entry by index

Source

pub fn use_last_result(&mut self)

Uses the last result as input for chained calculations

Trait Implementations§

Source§

impl Debug for WasmCalculator

Source§

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

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

impl Default for WasmCalculator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.