Trait garage_table::schema::TableSchema
source · pub trait TableSchema: Send + Sync + 'static {
type P: PartitionKey + Clone + PartialEq + Serialize + for<'de> Deserialize<'de> + Send + Sync;
type S: SortKey + Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync;
type E: Entry<Self::P, Self::S>;
type Filter: Clone + Serialize + for<'de> Deserialize<'de> + Send + Sync;
const TABLE_NAME: &'static str;
fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool;
fn try_migrate(_bytes: &[u8]) -> Option<Self::E> { ... }
fn updated(
&self,
_tx: &mut Transaction<'_>,
_old: Option<&Self::E>,
_new: Option<&Self::E>
) -> TxOpResult<()> { ... }
}
Expand description
Trait for the schema used in a table
Required Associated Types
sourcetype P: PartitionKey + Clone + PartialEq + Serialize + for<'de> Deserialize<'de> + Send + Sync
type P: PartitionKey + Clone + PartialEq + Serialize + for<'de> Deserialize<'de> + Send + Sync
The partition key used in that table
Required Associated Constants
sourceconst TABLE_NAME: &'static str
const TABLE_NAME: &'static str
The name of the table in the database
Required Methods
fn matches_filter(entry: &Self::E, filter: &Self::Filter) -> bool
Provided Methods
sourcefn try_migrate(_bytes: &[u8]) -> Option<Self::E>
fn try_migrate(_bytes: &[u8]) -> Option<Self::E>
Try migrating an entry from an older version
sourcefn updated(
&self,
_tx: &mut Transaction<'_>,
_old: Option<&Self::E>,
_new: Option<&Self::E>
) -> TxOpResult<()>
fn updated(
&self,
_tx: &mut Transaction<'_>,
_old: Option<&Self::E>,
_new: Option<&Self::E>
) -> TxOpResult<()>
Actions triggered by data changing in a table. If such actions include updates to the local database that should be applied atomically with the item update itself, a db transaction is provided on which these changes should be done. This function can return a DB error but that’s all.