mod error;
mod metadata;
mod mutation;
mod plan;
mod registry;
mod sql;
pub use error::TableStoreError;
pub use metadata::{
ColumnType, ForeignKey, PrimaryKey, RelationshipDef, RelationshipKind, RowKey, RowValue,
RowValues, TableColumn, TableIndex, TableSchema, DEFAULT_TABLE_VERSION_COLUMN,
};
pub(crate) use mutation::{
column_name_for, key_fingerprint, key_from_row, validate_delete_mutation,
validate_expected_version, validate_key, validate_patch_mutation, validate_row_mutation,
validate_row_values,
};
pub use mutation::{
DeleteTableRowMutation, ExpectedVersion, PatchMode, PatchTableRowMutation, RowPatch,
RowWriteMode, TableMutation, TableRowMutation,
};
pub use plan::{TableAdapterCapabilities, TableCommitOutcome, TableWritePlan};
pub use registry::{
TableMigrationArtifact, TableSchemaAdapter, TableSchemaAdapterCapabilities,
TableSchemaBootstrap, TableSchemaIssue, TableSchemaIssueKind, TableSchemaRegistry,
TableSchemaVerification,
};
pub use sql::{
bootstrap_result as table_schema_bootstrap_result, generate_table_migration_artifacts,
table_schema_statements, TableSqlDialect, TableSqlSchemaAdapter,
};
pub trait TableModel: Clone + Send + Sync + Sized {
fn table_schema() -> &'static TableSchema;
fn table_key(&self) -> Result<RowKey, TableStoreError>;
fn to_table_row(&self) -> Result<RowValues, TableStoreError>;
}
pub trait TableSchemaRegistryExt {
fn register_table<M>(&mut self) -> Result<&mut Self, TableStoreError>
where
M: TableModel;
}
impl TableSchemaRegistryExt for TableSchemaRegistry {
fn register_table<M>(&mut self) -> Result<&mut Self, TableStoreError>
where
M: TableModel,
{
self.register_schema(M::table_schema().clone())
}
}