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. Holding its other inputs fixed, substituting its outputs for overlapping inputs and applying it again produces equivalent outputs.
Every method in a relationship must conform the same constraint and preserve an assignment that already satisfies it. The runtime checks shared cell sets, not this semantic consistency.
§Examples
See the relationship example.
Implementations§
Source§impl Method
impl Method
Sourcepub fn new<F>(
inputs: Vec<CellId>,
outputs: Vec<CellId>,
input_types: Vec<TypeId>,
output_types: Vec<TypeId>,
f: F,
) -> Self
pub fn new<F>( inputs: Vec<CellId>, outputs: Vec<CellId>, input_types: Vec<TypeId>, output_types: Vec<TypeId>, f: F, ) -> Self
Creates a method from explicit TypeIds and a type-erased function.
- Precondition:
inputs.len() == input_types.len()andoutputs.len() == output_types.len(). - Precondition:
fsatisfiesMethod’s purity and idempotence contract.
Propagation validates the callback’s output count and concrete types before publishing staged values. Declared output order determines positional binding.
- Complexity: O(1) storage work, excluding ownership transfer of declared edges.
§Examples
See the relationship example.
Sourcepub fn from_fn_1_1<A, B, F>(input: CellId, output: CellId, f: F) -> Self
pub fn from_fn_1_1<A, B, F>(input: CellId, output: CellId, f: F) -> Self
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:
fsatisfiesMethod’s purity and idempotence contract.
§Examples
See the relationship example.
Sourcepub fn from_fn_2_1<A, B, C, F>(
inputs: [CellId; 2],
output: CellId,
f: F,
) -> Self
pub fn from_fn_2_1<A, B, C, F>( inputs: [CellId; 2], output: CellId, f: F, ) -> Self
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:
fsatisfiesMethod’s purity and idempotence contract.
§Examples
See the relationship example.