to_model

Function to_model 

Source
pub fn to_model<Id: IdType, DbId: PostgresIdType, Data: DataType, CODEC: JsonCodec<Data>, IdIdx: RowIndex + Display, VersionIdx: RowIndex + Display, CreateEpochMillisIdx: RowIndex + Display, UpdateEpochMillisIdx: RowIndex + Display, DataIdx: RowIndex + Display>(
    codec: &CODEC,
    id_generator: &dyn IdGenerator<Id, DbId>,
    row: &Row,
    id_index: IdIdx,
    version_index: VersionIdx,
    create_epoch_millis_index: CreateEpochMillisIdx,
    update_epoch_millis_index: UpdateEpochMillisIdx,
    data_index: DataIdx,
) -> Result<Model<Id, Data>, Box<dyn Error>>
Expand description

Converts a Row into a Model using the given index positions.

  • codec: The codec to use for serializing and deserializing the data.
  • id_generator: The id generator to use for converting the DbId to an Id.
  • row: The Row to convert to a Model.
  • id_index: The index of the id in the row.
  • version_index: The index of the version in the row.
  • create_epoch_millis_index: The index of the create epoch millis in the row.
  • update_epoch_millis_index: The index of the update epoch millis in the row.
  • data_index: The index of the data in the row.

Returns a Model with the converted id, version, create and update epoch millis, and data.

Errors if any of the positions are out of bounds, or if the id generator errors.