pub trait Computation:
'static
+ Sized
+ Clone {
type Storage;
type Output: Eq;
Show 13 methods
// Required methods
fn run(&self, handle: &mut DbHandle<'_, impl Computation>) -> Self::Output;
fn input_to_cell(input: &Self, storage: &Self::Storage) -> Option<Cell>;
fn insert_new_cell(cell: Cell, function: Self, storage: &mut Self::Storage);
fn get_function_and_output(
cell: Cell,
storage: &Self::Storage,
) -> (&Self, Option<&Self::Output>);
fn set_output(cell: Cell, output: Self::Output, storage: &mut Self::Storage);
// Provided methods
fn computation_id_of<T: Computation>() -> u32 { ... }
fn get_storage<Concrete: Computation + 'static>(
computation_id: u32,
container: &Self::Storage,
) -> &Concrete::Storage { ... }
fn get_storage_mut<Concrete: Computation + 'static>(
computation_id: u32,
container: &mut Self::Storage,
) -> &mut Concrete::Storage { ... }
fn output_is_unset<FullComputation: Computation>(
cell: Cell,
computation_id: u32,
original_computation_id: u32,
db: &Db<FullComputation>,
) -> bool { ... }
fn dispatch_run<FullComputation: Computation>(
cell: Cell,
computation_id: u32,
original_computation_id: u32,
db: &mut Db<FullComputation>,
) -> bool
where Self: Clone,
Self::Output: Eq { ... }
fn dispatch_update_output<Concrete, FullComputation>(
cell: Cell,
computation_id: u32,
original_computation_id: u32,
output: Concrete::Output,
db: &mut Db<FullComputation>,
) -> bool
where Concrete: Computation,
FullComputation: Computation,
Self::Output: Eq { ... }
fn dispatch_input_to_cell<Concrete>(
input: &Concrete,
container: &Self::Storage,
) -> Option<Cell>
where Concrete: 'static + Computation + Any { ... }
fn dispatch_insert_new_cell<Concrete>(
cell: Cell,
input: Concrete,
storage: &mut Self::Storage,
)
where Concrete: 'static + Computation + Any,
Concrete::Storage: 'static { ... }
}Required Associated Types§
Required Methods§
fn run(&self, handle: &mut DbHandle<'_, impl Computation>) -> Self::Output
fn input_to_cell(input: &Self, storage: &Self::Storage) -> Option<Cell>
fn insert_new_cell(cell: Cell, function: Self, storage: &mut Self::Storage)
fn get_function_and_output( cell: Cell, storage: &Self::Storage, ) -> (&Self, Option<&Self::Output>)
fn set_output(cell: Cell, output: Self::Output, storage: &mut Self::Storage)
Provided Methods§
fn computation_id_of<T: Computation>() -> u32
fn get_storage<Concrete: Computation + 'static>( computation_id: u32, container: &Self::Storage, ) -> &Concrete::Storage
fn get_storage_mut<Concrete: Computation + 'static>( computation_id: u32, container: &mut Self::Storage, ) -> &mut Concrete::Storage
Sourcefn output_is_unset<FullComputation: Computation>(
cell: Cell,
computation_id: u32,
original_computation_id: u32,
db: &Db<FullComputation>,
) -> bool
fn output_is_unset<FullComputation: Computation>( cell: Cell, computation_id: u32, original_computation_id: u32, db: &Db<FullComputation>, ) -> bool
True if this has any cached output
Sourcefn dispatch_run<FullComputation: Computation>(
cell: Cell,
computation_id: u32,
original_computation_id: u32,
db: &mut Db<FullComputation>,
) -> bool
fn dispatch_run<FullComputation: Computation>( cell: Cell, computation_id: u32, original_computation_id: u32, db: &mut Db<FullComputation>, ) -> bool
Given a Cell, TypeId pair dispatch to the correct run function
and return true if the value has changed. This should also cache
the new value if it has changed.
Note that in dispatch functions Self is always the concrete, non-tuple type.
Sourcefn dispatch_update_output<Concrete, FullComputation>(
cell: Cell,
computation_id: u32,
original_computation_id: u32,
output: Concrete::Output,
db: &mut Db<FullComputation>,
) -> bool
fn dispatch_update_output<Concrete, FullComputation>( cell: Cell, computation_id: u32, original_computation_id: u32, output: Concrete::Output, db: &mut Db<FullComputation>, ) -> bool
Dispatch to the correct update_output function to cache the new output
and return true if the value has changed.
Note that in dispatch functions Self is the current type being dispatched,
Concrete, if present, is the non-tuple type of the target computation,
and FullComputation is the type of the Db computation parameter which is
usually a tuple of every possible computation.
fn dispatch_input_to_cell<Concrete>(
input: &Concrete,
container: &Self::Storage,
) -> Option<Cell>where
Concrete: 'static + Computation + Any,
fn dispatch_insert_new_cell<Concrete>( cell: Cell, input: Concrete, storage: &mut Self::Storage, )
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.