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>
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