#[non_exhaustive]pub struct ViewDef {Show 13 fields
pub name: Identifier,
pub accessor_name: Identifier,
pub is_public: bool,
pub is_anonymous: bool,
pub fn_ptr: ViewFnPtr,
pub params: ProductType,
pub params_for_generate: ProductTypeDef,
pub return_type: AlgebraicType,
pub return_type_for_generate: AlgebraicTypeUse,
pub product_type_ref: AlgebraicTypeRef,
pub primary_key: Option<ColId>,
pub return_columns: Vec<ViewColumnDef>,
pub param_columns: Vec<ViewParamDef>,
}Expand description
A view exported by the module.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: IdentifierThe name of the view. This must be unique within the module.
accessor_name: IdentifierThe view identifier as defined in the module source.
Similar to [TableDef.accessor_name].
is_public: boolIs this a public or a private view? Currently only public views are supported. Private views may be supported in the future.
is_anonymous: boolIs this view anonymous?
An anonymous view does not know who called it.
Specifically, it is a view that has an AnonymousViewContext as its first argument.
This type does not have access to the Identity of the caller.
fn_ptr: ViewFnPtrIt represents the unique index of this view within the module.
Module contains separate list for anonymous and non-anonymous views,
so is_anonymous is needed to fully identify the view along with this index.
params: ProductTypeThe parameters of the view.
This ProductType need not be registered in the module’s Typespace.
params_for_generate: ProductTypeDefThe parameters of the view, formatted for client codegen.
This ProductType need not be registered in the module’s TypespaceForGenerate.
return_type: AlgebraicTypeThe return type of the view.
Either Option<T>, Vec<T>, or Query<T> where:
Tis aProductTypecontaining the columns of the viewTis registered in the module’s typespaceOption<T>refers toAlgebraicType::option()Vec<T>refers toAlgebraicType::array()Query<T>is a specialProductType{ __query__: T }
return_type_for_generate: AlgebraicTypeUseThe return type of the view, formatted for client codegen.
product_type_ref: AlgebraicTypeRefThe single source of truth for the view’s columns.
If a view can return only Option<T>, Vec<T>, or Query<T>,
this is a reference to the inner product type T.
All elements of T must have names.
primary_key: Option<ColId>The primary key of the view.
This is set for query-builder views when the underlying table has a primary key. The database engine does not actually care about this, but client code generation does.
return_columns: Vec<ViewColumnDef>The return columns of this view.
The same information is stored in product_type_ref.
This is just a more convenient-to-access format.
param_columns: Vec<ViewParamDef>The columns that track the arguments of this view.
The same information is stored in params.
This is just a more convenient-to-access format.
Implementations§
Source§impl ViewDef
impl ViewDef
Sourcepub fn get_column_by_name(&self, name: &Identifier) -> Option<&ViewColumnDef>
pub fn get_column_by_name(&self, name: &Identifier) -> Option<&ViewColumnDef>
Get a column by the column’s name.
Sourcepub fn get_param_by_name(&self, name: &Identifier) -> Option<&ViewParamDef>
pub fn get_param_by_name(&self, name: &Identifier) -> Option<&ViewParamDef>
Get a parameter by the parameter’s name.
Trait Implementations§
Source§impl From<ViewDef> for RawMiscModuleExportV9
impl From<ViewDef> for RawMiscModuleExportV9
Source§impl From<ViewDef> for RawViewDefV10
impl From<ViewDef> for RawViewDefV10
Source§impl From<ViewDef> for RawViewDefV9
impl From<ViewDef> for RawViewDefV9
Source§impl FunctionDef for ViewDef
impl FunctionDef for ViewDef
fn params(&self) -> &ProductType
fn name(&self) -> &Identifier
Source§impl ModuleDefLookup for ViewDef
impl ModuleDefLookup for ViewDef
Source§type Key<'a> = &'a Identifier
type Key<'a> = &'a Identifier
impl Eq for ViewDef
impl StructuralPartialEq for ViewDef
Auto Trait Implementations§
impl Freeze for ViewDef
impl RefUnwindSafe for ViewDef
impl Send for ViewDef
impl Sync for ViewDef
impl Unpin for ViewDef
impl UnsafeUnpin for ViewDef
impl UnwindSafe for ViewDef
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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