pub trait ForeignModel: StoredModel {
Show 13 methods
// 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 persist_foreign_with_plan(
value: Self,
foreign_plan: &ForeignWritePlan,
) -> impl Future<Output = Result<Self::Stored>> + Send
where Self: Send { ... }
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 supports_raw_partial_update() -> bool { ... }
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§
Sourcefn persist_foreign_with_plan(
value: Self,
foreign_plan: &ForeignWritePlan,
) -> impl Future<Output = Result<Self::Stored>> + Sendwhere
Self: Send,
fn persist_foreign_with_plan(
value: Self,
foreign_plan: &ForeignWritePlan,
) -> impl Future<Output = Result<Self::Stored>> + Sendwhere
Self: Send,
Rewrites a caller-facing value while allowing selected foreign fields to use caller-provided stored record-id shapes instead of persisting children.
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 supports_raw_partial_update() -> bool
fn supports_raw_partial_update() -> bool
Whether raw partial update APIs can return this model without Store-owned modifiers.
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".