pub trait ForeignModel: StoredModel {
// Required methods
fn persist_foreign(
value: Self,
) -> impl Future<Output = Result<Self::Stored>> + Send;
fn hydrate_foreign(
stored: Self::Stored,
) -> impl Future<Output = Result<Self>> + Send;
// Provided methods
fn has_foreign_fields() -> bool { ... }
fn foreign_field_names() -> &'static [&'static str] { ... }
fn has_relation_fields() -> bool { ... }
fn relation_field_names() -> &'static [&'static str] { ... }
fn strip_relation_fields(_row: &mut Value) { ... }
fn inject_relation_values_from_model(&self, _row: &mut Value) -> Result<()> { ... }
fn prepare_relation_writes(
&self,
_record: RecordId,
) -> impl Future<Output = Result<Vec<RelationWrite>>> + Send { ... }
fn inject_relation_values_from_db(
_record: RecordId,
_row: &mut Value,
) -> impl Future<Output = Result<()>> + Send { ... }
fn decode_stored_row(row: Value) -> Result<Self::Stored>
where Self::Stored: DeserializeOwned { ... }
}Expand description
Runtime seam for explicit nested #[foreign] persistence and hydration.
Required Methods§
Provided Methods§
fn has_foreign_fields() -> bool
Sourcefn foreign_field_names() -> &'static [&'static str]
fn foreign_field_names() -> &'static [&'static str]
Names of fields backed by #[foreign].
Sourcefn has_relation_fields() -> bool
fn has_relation_fields() -> bool
Whether the model contains any #[relate(...)] fields.
Sourcefn relation_field_names() -> &'static [&'static str]
fn relation_field_names() -> &'static [&'static str]
Names of fields backed by #[relate(...)].
Sourcefn strip_relation_fields(_row: &mut Value)
fn strip_relation_fields(_row: &mut Value)
Removes relation-backed fields from a serialized row before persistence.
Sourcefn inject_relation_values_from_model(&self, _row: &mut Value) -> Result<()>
fn inject_relation_values_from_model(&self, _row: &mut Value) -> Result<()>
Injects relation-backed field values from the caller-facing model into a serialized row.
Sourcefn prepare_relation_writes(
&self,
_record: RecordId,
) -> impl Future<Output = Result<Vec<RelationWrite>>> + Send
fn prepare_relation_writes( &self, _record: RecordId, ) -> impl Future<Output = Result<Vec<RelationWrite>>> + Send
Prepares ordered relation-table writes for this model value at record.
Sourcefn inject_relation_values_from_db(
_record: RecordId,
_row: &mut Value,
) -> impl Future<Output = Result<()>> + Send
fn inject_relation_values_from_db( _record: RecordId, _row: &mut Value, ) -> impl Future<Output = Result<()>> + Send
Loads relation-backed field values from edge tables into a serialized row.
Sourcefn decode_stored_row(row: Value) -> Result<Self::Stored>where
Self::Stored: DeserializeOwned,
fn decode_stored_row(row: Value) -> Result<Self::Stored>where
Self::Stored: DeserializeOwned,
Decodes a raw row returned by SurrealDB into the stored representation for this model.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.