Skip to main content

Reference

Trait Reference 

Source
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 resolve_as_any(&self, source_table: &dyn Any) -> Result<AnyTable>;
    fn target_type_name(&self) -> &'static str;

    // Provided method
    fn is_foreign(&self) -> bool { ... }
}
Expand description

Describes a relationship between two tables.

Required Methods§

Source

fn columns(&self, source_id: &str, target_id: &str) -> (String, String)

Given source and target id field names, return (source_column, target_column).

Source

fn build_target(&self, data_source: &dyn Any) -> Box<dyn Any>

Produce a fresh target table (no conditions applied).

Source

fn resolve_as_any(&self, source_table: &dyn Any) -> Result<AnyTable>

Resolve this reference and return an AnyTable.

For same-backend: builds target, applies condition, wraps in AnyTable. For foreign: returns the AnyTable from the user’s closure.

Source

fn target_type_name(&self) -> &'static str

Type name of the target table (for error messages).

Provided Methods§

Source

fn is_foreign(&self) -> bool

Whether this is a cross-persistence reference.

Implementors§

Source§

impl<T: TableSource + 'static, SourceE: Entity<T::Value> + 'static> Reference for HasForeign<T, SourceE>

Source§

impl<T: TableSource + 'static, SourceE: Entity<T::Value> + 'static, TargetE: Entity<T::Value> + 'static> Reference for HasMany<T, SourceE, TargetE>
where T::Value: Into<Value> + From<Value>, T::Id: Display + From<String>,

Source§

impl<T: TableSource + 'static, SourceE: Entity<T::Value> + 'static, TargetE: Entity<T::Value> + 'static> Reference for HasOne<T, SourceE, TargetE>
where T::Value: Into<Value> + From<Value>, T::Id: Display + From<String>,