Skip to main content

Method

Struct Method 

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

A single method within a relationship.

Its callback must be a pure, deterministic function of its input values and immutable captured constants, with no externally observable side effects. Equal inputs produce equivalent outputs or errors. There is no guarantee that the callback executes, or when or how often it executes. A self-referencing method must also be idempotent.

Implementations§

Source§

impl Method

Source

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

Creates a method from explicit TypeIds and a type-erased function.

  • Precondition: inputs.len() == input_types.len() and outputs.len() == output_types.len().
  • Precondition: The function must return exactly outputs.len() values in the correct order.
  • Precondition: f satisfies Method’s purity and idempotence contract.
Source

pub fn from_fn_1_1<A, B, F>(input: CellId, output: CellId, f: F) -> Self
where A: Any + 'static, B: Any + 'static, F: Fn(&A) -> Result<B, Error> + 'static,

Creates a 1-input, 1-output method from a typed closure.

TypeIds for A and B are captured automatically. The method is validated against its cell registrations when passed to crate::sheet::Sheet::add_relationship.

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

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

Creates a 2-input, 1-output method from a typed closure.

inputs[0] maps to A and inputs[1] maps to B. TypeIds are captured automatically. The method is validated when passed to crate::sheet::Sheet::add_relationship.

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Method

§

impl !Send for Method

§

impl !Sync for Method

§

impl !UnwindSafe for Method

§

impl Freeze for Method

§

impl Unpin for Method

§

impl UnsafeUnpin for Method

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.