Trait Versioned
pub trait Versioned:
Sized
+ Clone
+ Send
+ Sync
+ 'static {
type Key: Ord + Clone + Hash + Send + Sync + 'static;
const TABLE_NAME: &'static str;
// Required methods
fn table_id_cell() -> &'static OnceLock<TableId>;
fn key(&self) -> Self::Key;
fn key_bytes(&self) -> IndexKey;
fn indexes() -> &'static [IndexDesc<Self>];
// Provided method
fn table_id() -> TableId { ... }
}Expand description
A struct that the engine can store and version.
The bounds are the whole requirement: Clone because an update copies the
record before mutating it into a new version, Send + Sync + 'static because
versions outlive the transaction that wrote them. Fields are otherwise
unconstrained — there is no serialisation trait to satisfy.
Users never implement this by hand — #[derive(Mvcc)] generates it from
field attributes. It is public because it appears in the bounds of every
engine method, and because a hand implementation is a legitimate escape
hatch for exotic layouts.
Required Associated Constants§
const TABLE_NAME: &'static str
const TABLE_NAME: &'static str
Table name, used in diagnostics and error messages.
Required Associated Types§
Required Methods§
fn table_id_cell() -> &'static OnceLock<TableId>
fn table_id_cell() -> &'static OnceLock<TableId>
Storage for this type’s table id.
The derive emits a private static OnceLock<TableId> per type and
returns it here; Database::register fills it in. A OnceLock rather
than a const because ids are assigned in registration order, which is
not known until runtime.
fn key_bytes(&self) -> IndexKey
fn key_bytes(&self) -> IndexKey
The primary key in memcmp order, for the primary index.
fn indexes() -> &'static [IndexDesc<Self>]
fn indexes() -> &'static [IndexDesc<Self>]
Secondary indexes declared with #[mvcc(index)].
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".