Skip to main content

ViewDescriptor

Struct ViewDescriptor 

Source
pub struct ViewDescriptor<V, PK> {
    pub schema_name: &'static str,
    pub view_name: &'static str,
    pub columns: &'static [ModelColumn],
    pub primary_key: &'static str,
    pub allowed_fields: &'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 is_materialized: bool,
    pub source_tables: &'static [&'static str],
    /* private fields */
}

Fields§

§schema_name: &'static str§view_name: &'static str§columns: &'static [ModelColumn]§primary_key: &'static str

SQL column name of the view’s primary key. Empty string when the view was declared @@no_unique — in that case the macro also omits find_unique on the generated delegate.

§allowed_fields: &'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]§is_materialized: bool

true when the view was declared @@materialized. Embedded builds reject this at macro expansion time (SQLite has no materialized views); server builds emit a refresh() method.

§source_tables: &'static [&'static str]

Names of the models / views the SQL body reads from. Drives migration ordering — CREATE VIEW lands after its sources, DROP VIEW lands before them. Populated from the from M, N declaration on the schema, not parsed out of the SQL body.

Implementations§

Source§

impl<V, PK> ViewDescriptor<V, PK>

Source

pub const fn new( schema_name: &'static str, view_name: &'static str, columns: &'static [ModelColumn], primary_key: &'static str, allowed_fields: &'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], is_materialized: bool, source_tables: &'static [&'static str], ) -> Self

Trait Implementations§

Source§

impl<V: Clone, PK: Clone> Clone for ViewDescriptor<V, PK>

Source§

fn clone(&self) -> ViewDescriptor<V, 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<V: Debug, PK: Debug> Debug for ViewDescriptor<V, PK>

Source§

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

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

impl<V, PK> ReadSource<V, PK> for ViewDescriptor<V, PK>

Source§

fn schema_name(&self) -> &'static str

Logical schema name the model / view lives under. Currently always the dataset schema declared in 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

SQL identifier of the table or view this source reads from. Both backends quote it verbatim when constructing FROM clauses.
Source§

fn columns(&self) -> &'static [ModelColumn]

All projectable columns, ordered as the descriptor declares them. The read builder relies on this order when binding row decoders.
Source§

fn primary_key(&self) -> &'static str

SQL column name of the primary key. For views declared with @@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]

Names accepted in where = { <name>: <op> } filter payloads — the same allow-list the model uses for read-policy scoping.
Source§

fn allowed_includes(&self) -> &'static [&'static str]

Names accepted in 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]

Names accepted in orderBy = [ <name>, ... ] payloads.
Source§

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]

@@deny("read", ...) policy literals for the list shape.
Source§

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]

@@deny("read", ...) policy literals for the detail shape.
Source§

fn soft_delete_column(&self) -> Option<&'static str>

Soft-delete sentinel column name. 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

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

Like Self::select_projection but emits only the named columns. Unknown names are silently dropped — same contract as super::ModelDescriptor::select_projection_subset.
Source§

impl<V: Copy, PK: Copy> Copy for ViewDescriptor<V, PK>

Auto Trait Implementations§

§

impl<V, PK> Freeze for ViewDescriptor<V, PK>

§

impl<V, PK> RefUnwindSafe for ViewDescriptor<V, PK>

§

impl<V, PK> Send for ViewDescriptor<V, PK>

§

impl<V, PK> Sync for ViewDescriptor<V, PK>

§

impl<V, PK> Unpin for ViewDescriptor<V, PK>

§

impl<V, PK> UnsafeUnpin for ViewDescriptor<V, PK>

§

impl<V, PK> UnwindSafe for ViewDescriptor<V, 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, 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> 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.