pub trait Reference: Send + Sync {
// Required methods
fn columns(&self, source_id: &str, target_id: &str) -> (String, String);
fn vista_reference(
&self,
name: &str,
target: String,
source_id: &str,
) -> Reference;
fn build_target(&self, data_source: &dyn Any) -> Result<Box<dyn Any>>;
fn build_target_erased(&self, data_source: &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>>;
fn target_table_name(&self, data_source: &dyn Any) -> String;
}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 vista_reference(
&self,
name: &str,
target: String,
source_id: &str,
) -> Reference
fn vista_reference( &self, name: &str, target: String, source_id: &str, ) -> Reference
This relation as Vista metadata: a join named name onto target.
source_id is the source column a has_many reads its join value
from; a has_one ignores it and constrains the target’s id column,
resolved at traversal. Only joins implement this trait, so the result
is never a contained kind.
Sourcefn build_target(&self, data_source: &dyn Any) -> Result<Box<dyn Any>>
fn build_target(&self, data_source: &dyn Any) -> Result<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 crate::table::Table::get_ref_as and
crate::table::Table::get_subquery_as to build the target before
applying the join condition. Errors when the target can’t be built
(e.g. a spec reference whose target has no spec).
Sourcefn build_target_erased(&self, data_source: &dyn Any) -> Result<Box<dyn Any>>
fn build_target_erased(&self, data_source: &dyn Any) -> Result<Box<dyn Any>>
Produce a fresh target table with its entity type erased to
EmptyEntity, wrapped in Box<dyn Any> for downcast to
Table<T, EmptyEntity>. Unlike build_target,
the caller need not know the concrete target entity type — used by
implicit-reference traversal, which walks relations by name.
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_table_name(&self, data_source: &dyn Any) -> String
fn target_table_name(&self, data_source: &dyn Any) -> String
The name of the relation’s target in Vista metadata, which a catalog
resolves by name. A relation declared with a target name
(try_with_one / try_with_many, so every spec reference) returns
it without building the target, so a metadata snapshot runs no
target build and no injector; traversing it reports any build error.
Otherwise, the table name of the target built over data_source
(&T).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".