Skip to main content

InPlaceTransform

Trait InPlaceTransform 

Source
pub trait InPlaceTransform: Send + Sync {
    // Required method
    fn transform(
        &self,
        table: &str,
        id: &mut Value,
        fields: Option<&mut HashMap<String, Value>>,
    ) -> Result<(), Error>;

    // Provided methods
    fn transform_row(&self, row: &mut Row) -> Result<(), Error> { ... }
    fn transform_change(&self, change: &mut Change) -> Result<(), Error> { ... }
    fn transform_relation(&self, _relation: &mut Relation) -> Result<(), Error> { ... }
    fn transform_relation_change(
        &self,
        _change: &mut RelationChange,
    ) -> Result<(), Error> { ... }
    fn transform_rows_inplace(&self, rows: &mut [Row]) -> Result<(), Error> { ... }
    fn transform_changes_inplace(
        &self,
        changes: &mut [Change],
    ) -> Result<(), Error> { ... }
    fn transform_relations_inplace(
        &self,
        relations: &mut [Relation],
    ) -> Result<(), Error> { ... }
    fn transform_relation_changes_inplace(
        &self,
        changes: &mut [RelationChange],
    ) -> Result<(), Error> { ... }
}
Expand description

Mutate-only, same-length transform over sync docs.

This is the only in-process mutation primitive. Filter / fan-out belong in an external transform or outside this trait.

Implement transform once for the shared document surface (table / id / optional fields). transform_row and transform_change default to calling it. Deletes arrive with fields == None.

§Slice defaults

transform_rows_inplace and transform_changes_inplace loop over items by default. Override only when a batched implementation is faster.

Relation methods default to no-op so row-only transforms stay trivial.

Required Methods§

Source

fn transform( &self, table: &str, id: &mut Value, fields: Option<&mut HashMap<String, Value>>, ) -> Result<(), Error>

Mutate the shared document surface (id + optional field map).

fields is None for delete changes.

Provided Methods§

Source

fn transform_row(&self, row: &mut Row) -> Result<(), Error>

Transform a single row in place.

Source

fn transform_change(&self, change: &mut Change) -> Result<(), Error>

Transform a single change in place (including deletes).

Source

fn transform_relation(&self, _relation: &mut Relation) -> Result<(), Error>

Transform a single relation in place. Default: no-op.

Source

fn transform_relation_change( &self, _change: &mut RelationChange, ) -> Result<(), Error>

Transform a single relation change in place. Default: no-op.

Source

fn transform_rows_inplace(&self, rows: &mut [Row]) -> Result<(), Error>

Transform a slice of owned rows in place (true zero-copy path).

Source

fn transform_changes_inplace(&self, changes: &mut [Change]) -> Result<(), Error>

Transform a slice of owned changes in place (true zero-copy path).

Source

fn transform_relations_inplace( &self, relations: &mut [Relation], ) -> Result<(), Error>

Transform a slice of owned relations in place. Default: loop.

Source

fn transform_relation_changes_inplace( &self, changes: &mut [RelationChange], ) -> Result<(), Error>

Transform a slice of owned relation changes in place. Default: loop.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§