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 strSQL 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: booltrue 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>
impl<V, PK> ViewDescriptor<V, PK>
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>
impl<V: Clone, PK: Clone> Clone for ViewDescriptor<V, PK>
Source§fn clone(&self) -> ViewDescriptor<V, PK>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<V, PK> ReadSource<V, PK> for ViewDescriptor<V, PK>
impl<V, PK> ReadSource<V, PK> for ViewDescriptor<V, PK>
Source§fn schema_name(&self) -> &'static str
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
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]
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
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]
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]
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]
fn allowed_sorts(&self) -> &'static [&'static str]
Names accepted in
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>
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
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
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.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> 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
Mutably borrows from an owned value. Read more