pub struct JsonTable<T: 'static> {
pub name: &'static str,
pub primary_key: &'static str,
pub indexes: &'static [IndexSpec<T>],
pub unique_constraints: &'static [&'static [&'static str]],
}Expand description
Full table specification: name + the ordered list of indexed columns.
Shared across open/reopen so a downstream shim can keep the same layout forever without duplicating strings.
The 'static bound on T is required because indexes is a
&'static [IndexSpec<T>] — the compiler needs to know any T referenced
by the static slice is itself valid for 'static. Every concrete record
type we store (e.g. StoredNotifier) owns its data, so this bound is
always satisfied in practice.
Fields§
§name: &'static strSQL table name. Must be a valid SQL identifier; splat directly into DDL, so this MUST be a compile-time string literal.
primary_key: &'static strName of the primary-key column. Defaults to "id" for every store
created fresh by this codebase. It exists as a knob so a pre-existing
on-disk schema whose primary key is named something else can be routed
through this adapter without a destructive migration — the
deployments table, for instance, has had name TEXT PRIMARY KEY
since before the adapter existed, so it sets primary_key: "name".
Like every other identifier on this struct it is splat directly into
the DDL/queries, so it MUST be a compile-time string literal.
indexes: &'static [IndexSpec<T>]Indexed columns. May be empty for pure blob-only tables.
unique_constraints: &'static [&'static [&'static str]]Compound UNIQUE(col_a, col_b, ...) constraints emitted at
CREATE TABLE time. Each inner slice becomes one UNIQUE(...) clause
in the generated DDL. For single-column uniqueness prefer
IndexSpec::unique = true — it’s flatter. Use this field when
uniqueness spans two or more columns (e.g. UNIQUE(name, scope)).
Every column name referenced here MUST also appear in indexes so
that it’s peeled out of T at write time; otherwise the CREATE TABLE
statement will reference a column that doesn’t exist. The column names
are splat directly into the DDL, so they MUST be compile-time string
literals. May be empty when no compound constraints are needed.
Auto Trait Implementations§
impl<T> Freeze for JsonTable<T>
impl<T> RefUnwindSafe for JsonTable<T>
impl<T> Send for JsonTable<T>
impl<T> Sync for JsonTable<T>
impl<T> Unpin for JsonTable<T>
impl<T> UnsafeUnpin for JsonTable<T>
impl<T> UnwindSafe for JsonTable<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more