pub trait Reference: Send + Sync {
// Required methods
fn columns(&self, source_id: &str, target_id: &str) -> (String, String);
fn build_target(&self, data_source: &dyn Any) -> Box<dyn Any>;
fn cardinality(&self) -> ReferenceKind;
fn resolve_from_row(
&self,
data_source: &dyn Any,
source_id_field: &str,
source_row: &dyn Any,
) -> Result<Box<dyn Any>>;
fn resolve_as_any(&self, source_table: &dyn Any) -> Result<AnyTable>;
fn target_type_name(&self) -> &'static str;
}Expand description
Describes a relationship between two tables.
Required Methods§
Sourcefn columns(&self, source_id: &str, target_id: &str) -> (String, String)
fn columns(&self, source_id: &str, target_id: &str) -> (String, String)
Given source and target id field names, return (source_column, target_column).
Sourcefn build_target(&self, data_source: &dyn Any) -> Box<dyn Any>
fn build_target(&self, data_source: &dyn Any) -> Box<dyn Any>
Produce a fresh target table (no conditions applied).
Sourcefn cardinality(&self) -> ReferenceKind
fn cardinality(&self) -> ReferenceKind
Cardinality of this relation. HasOne if traversing yields at most
one record (the FK lives on the source); HasMany if it can yield
any number (the FK lives on the target). Surfaced by
Vista::list_references so CLIs / UIs can pick a record-card vs
list-grid renderer.
Sourcefn resolve_from_row(
&self,
data_source: &dyn Any,
source_id_field: &str,
source_row: &dyn Any,
) -> Result<Box<dyn Any>>
fn resolve_from_row( &self, data_source: &dyn Any, source_id_field: &str, source_row: &dyn Any, ) -> Result<Box<dyn Any>>
Resolve traversal using a known source row. Returns the target table
(entity type erased to EmptyEntity) wrapped in Box<dyn Any>, with
one eq-condition applied that selects the related rows.
data_source is &T for the source’s TableSource; source_id_field
is the name of the source table’s id column (needed by HasMany to
pull the join value out of the row); source_row is &Record<T::Value>.
HasOne ignores source_id_field and reads its stored foreign_key
instead.
Callers immediately downcast the result to Table<T, EmptyEntity>.
Sourcefn resolve_as_any(&self, source_table: &dyn Any) -> Result<AnyTable>
fn resolve_as_any(&self, source_table: &dyn Any) -> Result<AnyTable>
Resolve this reference and return an AnyTable.
Legacy path used by Table::get_ref / get_ref_as / get_subquery_as.
Slated for deletion in Stage 9 alongside AnyTable; new callers should
use resolve_from_row (typed) or Vista::get_ref (erased) instead.
Sourcefn target_type_name(&self) -> &'static str
fn target_type_name(&self) -> &'static str
Type name of the target table (for error messages).