Skip to main content

ModelDescriptor

Struct ModelDescriptor 

Source
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: bool

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

Source

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>

Source

pub fn emits(&self, operation: ModelEventKind) -> bool

Source

pub fn select_projection(&self) -> String

Source

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>
where M: Clone, PK: Clone,

Source§

fn clone(&self) -> ModelDescriptor<M, PK>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M, PK> Debug for ModelDescriptor<M, PK>
where M: Debug, PK: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<M, PK> Copy for ModelDescriptor<M, PK>
where M: Copy, PK: Copy,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,