Skip to main content

Filter

Struct Filter 

Source
pub struct Filter(/* private fields */);
Expand description

An idempotent, per-cell domain constraint with optional dynamic arguments.

Constructed via Filter::from_fn_0/Filter::from_fn_1/Filter::from_fn_2 for the common typed cases, or Filter::new for the fully type-erased form. Attached to a cell with crate::sheet::Sheet::add_filter.

Its callbacks must be pure, deterministic functions of their input values and immutable captured constants, with no externally observable side effects. Equal inputs produce equivalent outputs or errors. There is no guarantee that a callback executes, or when or how often it executes. This includes range-bound evaluators; the conforming callback must also be idempotent.

Implementations§

Source§

impl Filter

Source

pub fn new<F>( value_type: TypeId, args: Vec<CellId>, arg_types: Vec<TypeId>, f: F, ) -> Self
where F: Fn(&dyn Any, &[&dyn Any]) -> Result<Box<dyn Any>, Error> + 'static,

Creates a filter from an explicit value TypeId, argument TypeIds, and a type-erased function.

  • Precondition: args.len() == arg_types.len().
  • Precondition: f returns a value whose runtime type matches value_type.
  • Precondition: f satisfies Filter’s purity and idempotence contract.
Source

pub fn from_fn_0<T, F>(f: F) -> Self
where T: Any + 'static, F: Fn(&T) -> Result<T, Error> + 'static,

Creates a filter with no dynamic arguments from a typed closure.

The TypeId for T is captured automatically. The filter is validated against its cell registration when passed to crate::sheet::Sheet::add_filter.

  • Precondition: f satisfies Filter’s purity and idempotence contract.
Source

pub fn from_fn_1<A, T, F>(arg: CellId, f: F) -> Self
where A: Any + 'static, T: Any + 'static, F: Fn(&T, &A) -> Result<T, Error> + 'static,

Creates a filter with one dynamic argument cell from a typed closure.

TypeIds for A and T are captured automatically. The filter is validated against its cell registration when passed to crate::sheet::Sheet::add_filter.

  • Precondition: f satisfies Filter’s purity and idempotence contract.
Source

pub fn from_fn_2<A, B, T, F>(args: [CellId; 2], f: F) -> Self
where A: Any + 'static, B: Any + 'static, T: Any + 'static, F: Fn(&T, &A, &B) -> Result<T, Error> + 'static,

Creates a filter with two dynamic argument cells from a typed closure.

args[0] maps to A and args[1] maps to B. TypeIds for A, B, and T are captured automatically. The filter is validated when passed to crate::sheet::Sheet::add_filter.

  • Precondition: f satisfies Filter’s purity and idempotence contract.
Source

pub fn range<F, B>( value_type: TypeId, args: Vec<CellId>, arg_types: Vec<TypeId>, clamp: F, bounds: B, ) -> Self
where F: Fn(&dyn Any, &[&dyn Any]) -> Result<Box<dyn Any>, Error> + 'static, B: Fn(&[&dyn Any]) -> Option<(Box<dyn Any>, Box<dyn Any>)> + 'static,

Creates a range-clamp filter from an explicit value TypeId, argument TypeIds, a clamp function, and a bounds re-evaluator — the tagged counterpart of what Filter::new builds for FilterKind::Opaque. clamp is Filter’s actual per-write/per-propagate function (called exactly like an opaque filter’s); bounds is called independently, with no candidate value, by crate::sheet::Sheet::filter_range.

  • Precondition: args.len() == arg_types.len().
  • Precondition: clamp returns a value whose runtime type matches value_type.
  • Precondition: when bounds returns Some, the pair’s values have a runtime type matching value_type.
  • Precondition: clamp and bounds satisfy Filter’s purity contract; clamp is also idempotent.

Auto Trait Implementations§

§

impl !RefUnwindSafe for Filter

§

impl !Send for Filter

§

impl !Sync for Filter

§

impl !UnwindSafe for Filter

§

impl Freeze for Filter

§

impl Unpin for Filter

§

impl UnsafeUnpin for Filter

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.