Skip to main content

RawModuleDefV9Builder

Struct RawModuleDefV9Builder 

Source
pub struct RawModuleDefV9Builder { /* private fields */ }
Expand description

A builder for a RawModuleDefV9.

Implementations§

Source§

impl RawModuleDefV9Builder

Source

pub fn new() -> Self

Create a new, empty RawModuleDefBuilder.

Source

pub fn add_type<T: SpacetimeType>(&mut self) -> AlgebraicType

Add a type to the in-progress module.

The returned type must satisfy AlgebraicType::is_valid_for_client_type_definition or AlgebraicType::is_valid_for_client_type_use .

Source

pub fn build_table( &mut self, name: impl Into<RawIdentifier>, product_type_ref: AlgebraicTypeRef, ) -> RawTableDefBuilder<'_>

Create a table builder.

Does not validate that the product_type_ref is valid; this is left to the module validation code.

Source

pub fn build_table_with_new_type( &mut self, table_name: impl Into<RawIdentifier>, product_type: impl Into<ProductType>, custom_ordering: bool, ) -> RawTableDefBuilder<'_>

Build a new table with a product type. Adds the type to the module.

Source

pub fn build_table_with_new_type_for_tests( &mut self, table_name: impl Into<RawIdentifier>, product_type: ProductType, custom_ordering: bool, ) -> RawTableDefBuilder<'_>

Build a new table with a product type, for testing. Adds the type to the module.

Source

pub fn add_algebraic_type( &mut self, scope: impl IntoIterator<Item = RawIdentifier>, name: impl Into<RawIdentifier>, ty: AlgebraicType, custom_ordering: bool, ) -> AlgebraicTypeRef

Add a type to the typespace, along with a type alias declaring its name. This method should only be use for AlgebraicTypes not corresponding to a Rust type that implements SpacetimeType.

Returns a reference to the newly-added type.

NOT idempotent, calling this twice with the same name will cause errors during validation.

You must set custom_ordering if you’re not using the default element ordering.

Source

pub fn add_reducer( &mut self, name: impl Into<RawIdentifier>, params: ProductType, lifecycle: Option<Lifecycle>, )

Add a reducer to the in-progress module. Accepts a ProductType of reducer arguments for convenience. The ProductType need not be registered in the typespace.

Importantly, if the reducer’s first argument is a ReducerContext, that information should not be provided to this method. That is an implementation detail handled by the module bindings and can be ignored. As far as the module definition is concerned, the reducer’s arguments start with the first non-ReducerContext argument.

(It is impossible, with the current implementation of ReducerContext, to have more than one ReducerContext argument, at least in Rust. This is because SpacetimeType is not implemented for ReducerContext, so it can never act like an ordinary argument.)

Source

pub fn add_procedure( &mut self, name: impl Into<RawIdentifier>, params: ProductType, return_type: AlgebraicType, )

Add a procedure to the in-progress module.

Accepts a ProductType of arguments. The arguments ProductType need not be registered in the typespace.

Also accepts an AlgebraicType return type. If this is a user-defined product or sum type, it should be registered in the typespace and indirected through an AlgebraicType::Ref.

The &mut ProcedureContext first argument to the procedure should not be included in the params.

Source

pub fn add_view( &mut self, name: impl Into<RawIdentifier>, index: usize, is_public: bool, is_anonymous: bool, params: ProductType, return_type: AlgebraicType, )

Source

pub fn add_row_level_security(&mut self, sql: &str)

Add a row-level security policy to the module.

The sql expression should be a valid SQL expression that will be used to filter rows.

NOTE: The sql expression must be unique within the module.

Source

pub fn typespace(&self) -> &Typespace

Get the typespace of the module.

Source

pub fn finish(self) -> RawModuleDefV9

Finish building, consuming the builder and returning the module. The module should be validated before use.

Trait Implementations§

Source§

impl Default for RawModuleDefV9Builder

Source§

fn default() -> RawModuleDefV9Builder

Returns the “default value” for a type. Read more
Source§

impl TypespaceBuilder for RawModuleDefV9Builder

Source§

fn add( &mut self, typeid: TypeId, name: Option<&'static str>, make_ty: impl FnOnce(&mut Self) -> AlgebraicType, ) -> AlgebraicType

Returns and adds a representation of type T: 'static as an AlgebraicType with an optional name to the typing context in self.
Source§

fn add_type<T>(&mut self) -> AlgebraicType
where T: SpacetimeType, Self: Sized,

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.