mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-26 20:36:00 +00:00
272ef18eb6
* database: add `bytemuck` * database: add `types` module, replace `Pod` with `bytemuck` traits * types: docs * types: more docs * types: align safety msg * types: docs * misc docs * add `storable.rs` * add `slice.rs` * storable: impl `impl_storable_checked_bit_pattern!()` * database: TODO: fix `DatabaseRo::get_range` lifetimes * key/table: trait bound fixes * misc fixes * remove `borsh` - Doesn't work on must types - Probably won't use it anyway - Most things impl `serde` * key: add `new_with_max_secondary()` * key: add `new_with_max_secondary()` * heed: add `StorableHeed` for `Storable` compat * redb: add `StorableRedb{Key,Value}` for `Storable` compat * storable: add `Debug` bound and `fixed_width()` * redb: fix `'static` bound * storable: docs * `pod.rs` tests -> `storable.rs` * redb: add `Storable` tests * storable: add doc tests * redb: simplify `Storable` tests * heed: add `Storable` tests * misc docs/fixes * cargo: switch from forked `heed` -> `heed 0.20.0-alpha.9` * update readme * docs * fix README * table: remove `CONSTANT_SIZE` * database: `get()/delete() -> Err(KeyNotFound)` instead of `Option`
44 lines
1.6 KiB
Rust
44 lines
1.6 KiB
Rust
//! Database table abstraction; `trait Table`.
|
|
|
|
//---------------------------------------------------------------------------------------------------- Import
|
|
use crate::{key::Key, storable::Storable};
|
|
|
|
//---------------------------------------------------------------------------------------------------- Table
|
|
/// Database table metadata.
|
|
///
|
|
/// Purely compile time information for database tables.
|
|
///
|
|
/// ## Sealed
|
|
/// This trait is [`Sealed`](https://rust-lang.github.io/api-guidelines/future-proofing.html#sealed-traits-protect-against-downstream-implementations-c-sealed).
|
|
///
|
|
/// It is, and can only be implemented on the types inside [`tables`][crate::tables].
|
|
pub trait Table: crate::tables::private::Sealed {
|
|
/// Name of the database table.
|
|
const NAME: &'static str;
|
|
|
|
// TODO:
|
|
//
|
|
// `redb` requires `K/V` is `'static`:
|
|
// - <https://docs.rs/redb/1.5.0/redb/struct.ReadOnlyTable.html>
|
|
// - <https://docs.rs/redb/1.5.0/redb/struct.Table.html>
|
|
//
|
|
// ...but kinda not really?
|
|
// "Note that the lifetime of the K and V type parameters does not impact
|
|
// the lifetimes of the data that is stored or retrieved from the table"
|
|
// <https://docs.rs/redb/1.5.0/redb/struct.TableDefinition.html>
|
|
//
|
|
// This might be incompatible with `heed`. We'll see
|
|
// after function bodies are actually implemented...
|
|
|
|
/// Primary key type.
|
|
type Key: Key + 'static;
|
|
|
|
/// Value type.
|
|
type Value: Storable + ?Sized + 'static;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------------------------------- Tests
|
|
#[cfg(test)]
|
|
mod test {
|
|
// use super::*;
|
|
}
|