Skip to main content

ViewDef

Struct ViewDef 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: Identifier

The name of the view. This must be unique within the module.

§accessor_name: Identifier

The view identifier as defined in the module source.

Similar to [TableDef.accessor_name].

§is_public: bool

Is this a public or a private view? Currently only public views are supported. Private views may be supported in the future.

§is_anonymous: bool

Is 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: ViewFnPtr

It 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: ProductType

The parameters of the view.

This ProductType need not be registered in the module’s Typespace.

§params_for_generate: ProductTypeDef

The parameters of the view, formatted for client codegen.

This ProductType need not be registered in the module’s TypespaceForGenerate.

§return_type: AlgebraicType

The return type of the view. Either Option<T>, Vec<T>, or Query<T> where:

  1. T is a ProductType containing the columns of the view
  2. T is registered in the module’s typespace
  3. Option<T> refers to AlgebraicType::option()
  4. Vec<T> refers to AlgebraicType::array()
  5. Query<T> is a special ProductType { __query__: T }
§return_type_for_generate: AlgebraicTypeUse

The return type of the view, formatted for client codegen.

§product_type_ref: AlgebraicTypeRef

The 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

Source

pub fn get_column_by_name(&self, name: &Identifier) -> Option<&ViewColumnDef>

Get a column by the column’s name.

Source

pub fn get_param_by_name(&self, name: &Identifier) -> Option<&ViewParamDef>

Get a parameter by the parameter’s name.

Trait Implementations§

Source§

impl Clone for ViewDef

Source§

fn clone(&self) -> ViewDef

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ViewDef

Source§

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

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

impl From<ViewDef> for RawMiscModuleExportV9

Source§

fn from(def: ViewDef) -> Self

Converts to this type from the input type.
Source§

impl From<ViewDef> for RawViewDefV10

Source§

fn from(val: ViewDef) -> Self

Converts to this type from the input type.
Source§

impl From<ViewDef> for RawViewDefV9

Source§

fn from(val: ViewDef) -> Self

Converts to this type from the input type.
Source§

impl From<ViewDef> for TableDef

Source§

fn from(def: ViewDef) -> Self

Converts to this type from the input type.
Source§

impl FunctionDef for ViewDef

Source§

impl ModuleDefLookup for ViewDef

Source§

type Key<'a> = &'a Identifier

A reference to a definition of this type within a module def. This reference should be portable across migrations.
Source§

fn key(&self) -> Self::Key<'_>

Get a reference to this definition.
Source§

fn lookup<'a>(view_def: &'a ModuleDef, key: Self::Key<'_>) -> Option<&'a Self>

Look up this entity in the module def.
Source§

impl PartialEq for ViewDef

Source§

fn eq(&self, other: &ViewDef) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ViewDef

Source§

impl StructuralPartialEq for ViewDef

Auto Trait Implementations§

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.