Skip to main content

RecordMapper

Trait RecordMapper 

Source
pub trait RecordMapper: Send + Sync {
    type Item: Clone + Send + Sync;

    // Required methods
    fn record_type(&self) -> &str;
    fn header(&self, item: &Self::Item) -> ItemHeader;
    fn encode(&self, item: &Self::Item, record: &mut RawRecord);
    fn decode(&self, record: &RawRecord) -> Result<Self::Item, String>;

    // Provided methods
    fn record_name(&self, id: &str) -> String { ... }
    fn tombstone_keep_fields(&self) -> &[&str] { ... }
}
Expand description

Domain <-> wire mapping for the one syncable item type.

Required Associated Types§

Required Methods§

Source

fn record_type(&self) -> &str

Source

fn header(&self, item: &Self::Item) -> ItemHeader

Source

fn encode(&self, item: &Self::Item, record: &mut RawRecord)

Write the domain fields. The engine has already set id, createdAt and updatedAt from header and cleared deletedAt.

Source

fn decode(&self, record: &RawRecord) -> Result<Self::Item, String>

Decode a live (non-tombstone) record; Err quarantines the record.

Provided Methods§

Source

fn record_name(&self, id: &str) -> String

Record name for an item id (default: the id itself).

Source

fn tombstone_keep_fields(&self) -> &[&str]

Extra fields a tombstone keeps beyond id/updatedAt/deletedAt.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§