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 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), wrapped in
Box<dyn Any> so callers can downcast back to the concrete
Table<T, TargetE>. Used by [Table::get_ref_as] and
[Table::get_subquery_as] to build the target before applying the
join condition.
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 target_type_name(&self) -> &'static str
fn target_type_name(&self) -> &'static str
Type name of the target table (for error messages).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".