Struct Input

Source
pub struct Input<T>(/* private fields */);
Expand description

Helper to define a Computation for an input type which has no dependencies and thus requires an explicit update from db.update_input to be initialized instead of a run function.

When using an input in a Computation tuple, you still need to decide on a storage type wrapper. An example would be HashMapStorage<Input<T>>.

Examples include struct FileContents { text: String }; or struct Time;

Implementations§

Source§

impl<T> Input<T>

Source

pub const fn new(value: T) -> Self

Trait Implementations§

Source§

impl<T: Clone> Clone for Input<T>

Source§

fn clone(&self) -> Input<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: OutputTypeForInput + 'static> Computation for Input<T>

Source§

type Output = <T as OutputTypeForInput>::Output

Source§

type Storage = (Option<Cell>, Option<<Input<T> as Computation>::Output>)

Source§

fn run(&self, _: &mut DbHandle<'_, impl Computation>) -> Self::Output

Source§

fn input_to_cell(_: &Self, _: &Self::Storage) -> Option<Cell>

Source§

fn get_function_and_output( _: Cell, _: &Self::Storage, ) -> (&Self, Option<&Self::Output>)

Source§

fn set_output(_: Cell, _: Self::Output, _: &mut Self::Storage)

Source§

fn insert_new_cell(_: Cell, _: Self, _: &mut Self::Storage)

Source§

fn computation_id_of<T: Computation>() -> u32

Source§

fn get_storage<Concrete: Computation + 'static>( computation_id: u32, container: &Self::Storage, ) -> &Concrete::Storage

Source§

fn get_storage_mut<Concrete: Computation + 'static>( computation_id: u32, container: &mut Self::Storage, ) -> &mut Concrete::Storage

Source§

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
Source§

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,

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.
Source§

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,

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.
Source§

fn dispatch_input_to_cell<Concrete>( input: &Concrete, container: &Self::Storage, ) -> Option<Cell>
where Concrete: 'static + Computation + Any,

Source§

fn dispatch_insert_new_cell<Concrete>( cell: Cell, input: Concrete, storage: &mut Self::Storage, )
where Concrete: 'static + Computation + Any, Concrete::Storage: 'static,

Source§

impl<T: Debug> Debug for Input<T>

Source§

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

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

impl<T: Default> Default for Input<T>

Source§

fn default() -> Input<T>

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

impl<T: Hash> Hash for Input<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Ord> Ord for Input<T>

Source§

fn cmp(&self, other: &Input<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq> PartialEq for Input<T>

Source§

fn eq(&self, other: &Input<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd> PartialOrd for Input<T>

Source§

fn partial_cmp(&self, other: &Input<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<T: Copy> Copy for Input<T>

Source§

impl<T: Eq> Eq for Input<T>

Source§

impl<T> StructuralPartialEq for Input<T>

Auto Trait Implementations§

§

impl<T> Freeze for Input<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Input<T>
where T: RefUnwindSafe,

§

impl<T> Send for Input<T>
where T: Send,

§

impl<T> Sync for Input<T>
where T: Sync,

§

impl<T> Unpin for Input<T>
where T: Unpin,

§

impl<T> UnwindSafe for Input<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<N> NodeTrait for N
where N: Copy + Ord + Hash,