pub struct ModelDescriptor<M, PK> {Show 26 fields
pub schema_name: &'static str,
pub table_name: &'static str,
pub columns: &'static [ModelColumn],
pub primary_key: &'static str,
pub allowed_fields: &'static [&'static str],
pub allowed_includes: &'static [&'static str],
pub allowed_sorts: &'static [&'static str],
pub read_allow_policies: &'static [ReadPolicy],
pub read_deny_policies: &'static [ReadPolicy],
pub detail_allow_policies: &'static [ReadPolicy],
pub detail_deny_policies: &'static [ReadPolicy],
pub create_allow_policies: &'static [ReadPolicy],
pub create_deny_policies: &'static [ReadPolicy],
pub update_allow_policies: &'static [ReadPolicy],
pub update_deny_policies: &'static [ReadPolicy],
pub delete_allow_policies: &'static [ReadPolicy],
pub delete_deny_policies: &'static [ReadPolicy],
pub create_defaults: &'static [CreateDefault],
pub emitted_events: &'static [ModelEventKind],
pub version_column: Option<&'static str>,
pub audit_enabled: bool,
pub pii_columns: &'static [&'static str],
pub sensitive_columns: &'static [&'static str],
pub soft_delete_column: Option<&'static str>,
pub retention_days: Option<u32>,
pub upsert_update_columns: &'static [&'static str],
/* private fields */
}Fields§
§schema_name: &'static str§table_name: &'static str§columns: &'static [ModelColumn]§primary_key: &'static str§allowed_fields: &'static [&'static str]§allowed_includes: &'static [&'static str]§allowed_sorts: &'static [&'static str]§read_allow_policies: &'static [ReadPolicy]§read_deny_policies: &'static [ReadPolicy]§detail_allow_policies: &'static [ReadPolicy]§detail_deny_policies: &'static [ReadPolicy]§create_allow_policies: &'static [ReadPolicy]§create_deny_policies: &'static [ReadPolicy]§update_allow_policies: &'static [ReadPolicy]§update_deny_policies: &'static [ReadPolicy]§delete_allow_policies: &'static [ReadPolicy]§delete_deny_policies: &'static [ReadPolicy]§create_defaults: &'static [CreateDefault]§emitted_events: &'static [ModelEventKind]§version_column: Option<&'static str>Column name of the optimistic-locking version field, set when the
model declares an @version field. None for non-versioned models,
which keeps update semantics unchanged.
audit_enabled: booltrue when the model declared @@audit. Mutations on audit-enabled
models capture before/after snapshots and persist them into
cratestack_audit inside the same transaction.
pii_columns: &'static [&'static str]SQL column names of fields declared @pii. The audit-log writer
replaces these values with "[redacted-pii]" in the persisted JSON
snapshots; a follow-up will extend the same redaction to error
detail and tracing.
sensitive_columns: &'static [&'static str]SQL column names of fields declared @sensitive. Redacted in audit
snapshots as "[redacted-sensitive]".
soft_delete_column: Option<&'static str>Column name for the soft-delete timestamp. When Some, DELETE
operations become UPDATE-of-deleted_at and every SELECT through
push_scoped_conditions filters out rows where the column is
non-null. Defaults to Some("deleted_at") when @@soft_delete is
declared.
retention_days: Option<u32>Retention window in days for soft-deleted rows. The runtime does
not auto-GC; banks run their own scheduled job that deletes rows
where deleted_at < NOW() - retention. Surfaced here so the GC
can read the policy from one place.
upsert_update_columns: &'static [&'static str]Columns the upsert primitive is allowed to overwrite on conflict.
Populated by the macro to be every scalar column except the
primary key, created_at, and the @version column. Empty when
the model has no eligible columns (e.g. PK-only); in that case
the macro doesn’t emit an UpsertModelInput impl either, so this
is just a belt-and-braces.
Implementations§
Source§impl<M, PK> ModelDescriptor<M, PK>
impl<M, PK> ModelDescriptor<M, PK>
pub const fn new( schema_name: &'static str, table_name: &'static str, columns: &'static [ModelColumn], primary_key: &'static str, allowed_fields: &'static [&'static str], allowed_includes: &'static [&'static str], allowed_sorts: &'static [&'static str], read_allow_policies: &'static [ReadPolicy], read_deny_policies: &'static [ReadPolicy], detail_allow_policies: &'static [ReadPolicy], detail_deny_policies: &'static [ReadPolicy], create_allow_policies: &'static [ReadPolicy], create_deny_policies: &'static [ReadPolicy], update_allow_policies: &'static [ReadPolicy], update_deny_policies: &'static [ReadPolicy], delete_allow_policies: &'static [ReadPolicy], delete_deny_policies: &'static [ReadPolicy], create_defaults: &'static [CreateDefault], emitted_events: &'static [ModelEventKind], version_column: Option<&'static str>, audit_enabled: bool, pii_columns: &'static [&'static str], sensitive_columns: &'static [&'static str], soft_delete_column: Option<&'static str>, retention_days: Option<u32>, upsert_update_columns: &'static [&'static str], ) -> ModelDescriptor<M, PK>
pub fn emits(&self, operation: ModelEventKind) -> bool
pub fn select_projection(&self) -> String
Sourcepub fn select_projection_subset(&self, columns: &[&str]) -> String
pub fn select_projection_subset(&self, columns: &[&str]) -> String
Like Self::select_projection but emits only the named
columns, in the order they appear in the model descriptor.
Unknown column names are silently dropped — the caller is
expected to have validated the request via FieldRef already
(typed-builder path) or via schema validation
(string-name path). When no columns survive the filter, the
primary key is emitted as a fallback so the SQL still binds
at least one column to the projection.
Trait Implementations§
Source§impl<M, PK> Clone for ModelDescriptor<M, PK>
impl<M, PK> Clone for ModelDescriptor<M, PK>
Source§fn clone(&self) -> ModelDescriptor<M, PK>
fn clone(&self) -> ModelDescriptor<M, PK>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<M, PK> Debug for ModelDescriptor<M, PK>
impl<M, PK> Debug for ModelDescriptor<M, PK>
Source§impl<M, PK> ReadSource<M, PK> for ModelDescriptor<M, PK>
impl<M, PK> ReadSource<M, PK> for ModelDescriptor<M, PK>
Source§fn schema_name(&self) -> &'static str
fn schema_name(&self) -> &'static str
datasource db { ... };
kept on the trait so future per-source schemas (e.g. analytics
views in a dedicated schema) are a non-breaking change.Source§fn table_name(&self) -> &'static str
fn table_name(&self) -> &'static str
FROM
clauses.Source§fn columns(&self) -> &'static [ModelColumn]
fn columns(&self) -> &'static [ModelColumn]
Source§fn primary_key(&self) -> &'static str
fn primary_key(&self) -> &'static str
@@no_unique (ADR-0003 §“Schema surface”) this is the empty
string — find_unique is not emitted on the delegate so the
builder never reads this slot.Source§fn allowed_fields(&self) -> &'static [&'static str]
fn allowed_fields(&self) -> &'static [&'static str]
where = { <name>: <op> } filter payloads
— the same allow-list the model uses for read-policy scoping.Source§fn allowed_includes(&self) -> &'static [&'static str]
fn allowed_includes(&self) -> &'static [&'static str]
include = { <name>: ... } payloads. Empty
on views in v1 (relation-follow off a view is out of scope —
see ADR-0003 “Deferred”).Source§fn allowed_sorts(&self) -> &'static [&'static str]
fn allowed_sorts(&self) -> &'static [&'static str]
orderBy = [ <name>, ... ] payloads.Source§fn read_allow_policies(&self) -> &'static [ReadPolicy]
fn read_allow_policies(&self) -> &'static [ReadPolicy]
@@allow("read", ...) policy literals for the list / search
shape (returns one row per matching record).Source§fn read_deny_policies(&self) -> &'static [ReadPolicy]
fn read_deny_policies(&self) -> &'static [ReadPolicy]
@@deny("read", ...) policy literals for the list shape.Source§fn detail_allow_policies(&self) -> &'static [ReadPolicy]
fn detail_allow_policies(&self) -> &'static [ReadPolicy]
@@allow("read", ...) policy literals for the detail shape
(find_unique — returns at most one record). Models can carry
stricter detail policies than list ones; views inherit a
single set declared via @@allow("read", ...) on the view
itself.Source§fn detail_deny_policies(&self) -> &'static [ReadPolicy]
fn detail_deny_policies(&self) -> &'static [ReadPolicy]
@@deny("read", ...) policy literals for the detail shape.Source§fn soft_delete_column(&self) -> Option<&'static str>
fn soft_delete_column(&self) -> Option<&'static str>
None on views (and on
models without @@soft_delete), in which case the read
builder skips the <col> IS NULL predicate it would otherwise
inject.Source§fn select_projection(&self) -> String
fn select_projection(&self) -> String
<col> AS "<alias>", ... projection list the
builder splices into SELECT. The default impl delegates to
Self::columns so any descriptor that just stores a column
list gets a working projection for free.Source§fn select_projection_subset(&self, columns: &[&str]) -> String
fn select_projection_subset(&self, columns: &[&str]) -> String
Self::select_projection but emits only the named
columns. Unknown names are silently dropped — same contract
as super::ModelDescriptor::select_projection_subset.Source§impl<M, PK> WriteSource<M, PK> for ModelDescriptor<M, PK>
impl<M, PK> WriteSource<M, PK> for ModelDescriptor<M, PK>
fn create_allow_policies(&self) -> &'static [ReadPolicy]
fn create_deny_policies(&self) -> &'static [ReadPolicy]
fn update_allow_policies(&self) -> &'static [ReadPolicy]
fn update_deny_policies(&self) -> &'static [ReadPolicy]
fn delete_allow_policies(&self) -> &'static [ReadPolicy]
fn delete_deny_policies(&self) -> &'static [ReadPolicy]
fn create_defaults(&self) -> &'static [CreateDefault]
fn emitted_events(&self) -> &'static [ModelEventKind]
Source§fn version_column(&self) -> Option<&'static str>
fn version_column(&self) -> Option<&'static str>
@version). None for
non-versioned models.Source§fn audit_enabled(&self) -> bool
fn audit_enabled(&self) -> bool
true when the model declared @@audit.fn pii_columns(&self) -> &'static [&'static str]
fn sensitive_columns(&self) -> &'static [&'static str]
Source§fn retention_days(&self) -> Option<u32>
fn retention_days(&self) -> Option<u32>
ReadSource) so the operator’s GC
job can read both pieces from one place.Source§fn upsert_update_columns(&self) -> &'static [&'static str]
fn upsert_update_columns(&self) -> &'static [&'static str]
impl<M, PK> Copy for ModelDescriptor<M, PK>
Auto Trait Implementations§
impl<M, PK> Freeze for ModelDescriptor<M, PK>
impl<M, PK> RefUnwindSafe for ModelDescriptor<M, PK>
impl<M, PK> Send for ModelDescriptor<M, PK>
impl<M, PK> Sync for ModelDescriptor<M, PK>
impl<M, PK> Unpin for ModelDescriptor<M, PK>
impl<M, PK> UnsafeUnpin for ModelDescriptor<M, PK>
impl<M, PK> UnwindSafe for ModelDescriptor<M, PK>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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