pub struct RawModuleDefV9Builder { /* private fields */ }Expand description
A builder for a RawModuleDefV9.
Implementations§
Source§impl RawModuleDefV9Builder
impl RawModuleDefV9Builder
Sourcepub fn add_type<T: SpacetimeType>(&mut self) -> AlgebraicType
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 .
Sourcepub fn build_table(
&mut self,
name: impl Into<RawIdentifier>,
product_type_ref: AlgebraicTypeRef,
) -> RawTableDefBuilder<'_>
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.
Sourcepub fn build_table_with_new_type(
&mut self,
table_name: impl Into<RawIdentifier>,
product_type: impl Into<ProductType>,
custom_ordering: bool,
) -> RawTableDefBuilder<'_>
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.
Sourcepub fn build_table_with_new_type_for_tests(
&mut self,
table_name: impl Into<RawIdentifier>,
product_type: ProductType,
custom_ordering: bool,
) -> RawTableDefBuilder<'_>
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.
Sourcepub fn add_algebraic_type(
&mut self,
scope: impl IntoIterator<Item = RawIdentifier>,
name: impl Into<RawIdentifier>,
ty: AlgebraicType,
custom_ordering: bool,
) -> AlgebraicTypeRef
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.
Sourcepub fn add_reducer(
&mut self,
name: impl Into<RawIdentifier>,
params: ProductType,
lifecycle: Option<Lifecycle>,
)
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.)
Sourcepub fn add_procedure(
&mut self,
name: impl Into<RawIdentifier>,
params: ProductType,
return_type: AlgebraicType,
)
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.
pub fn add_view( &mut self, name: impl Into<RawIdentifier>, index: usize, is_public: bool, is_anonymous: bool, params: ProductType, return_type: AlgebraicType, )
Sourcepub fn add_row_level_security(&mut self, sql: &str)
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.
Sourcepub fn finish(self) -> RawModuleDefV9
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
impl Default for RawModuleDefV9Builder
Source§fn default() -> RawModuleDefV9Builder
fn default() -> RawModuleDefV9Builder
Source§impl TypespaceBuilder for RawModuleDefV9Builder
impl TypespaceBuilder for RawModuleDefV9Builder
Source§fn add(
&mut self,
typeid: TypeId,
name: Option<&'static str>,
make_ty: impl FnOnce(&mut Self) -> AlgebraicType,
) -> AlgebraicType
fn add( &mut self, typeid: TypeId, name: Option<&'static str>, make_ty: impl FnOnce(&mut Self) -> AlgebraicType, ) -> AlgebraicType
T: 'static as an AlgebraicType
with an optional name to the typing context in self.fn add_type<T>(&mut self) -> AlgebraicTypewhere
T: SpacetimeType,
Self: Sized,
Auto Trait Implementations§
impl Freeze for RawModuleDefV9Builder
impl RefUnwindSafe for RawModuleDefV9Builder
impl Send for RawModuleDefV9Builder
impl Sync for RawModuleDefV9Builder
impl Unpin for RawModuleDefV9Builder
impl UnsafeUnpin for RawModuleDefV9Builder
impl UnwindSafe for RawModuleDefV9Builder
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> 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