pub struct RawModuleDefV10Builder { /* private fields */ }Expand description
A builder for a RawModuleDefV10.
Implementations§
Source§impl RawModuleDefV10Builder
impl RawModuleDefV10Builder
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,
source_name: impl Into<RawIdentifier>,
product_type_ref: AlgebraicTypeRef,
) -> RawTableDefBuilderV10<'_>
pub fn build_table( &mut self, source_name: impl Into<RawIdentifier>, product_type_ref: AlgebraicTypeRef, ) -> RawTableDefBuilderV10<'_>
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,
) -> RawTableDefBuilderV10<'_>
pub fn build_table_with_new_type( &mut self, table_name: impl Into<RawIdentifier>, product_type: impl Into<ProductType>, custom_ordering: bool, ) -> RawTableDefBuilderV10<'_>
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,
) -> RawTableDefBuilderV10<'_>
pub fn build_table_with_new_type_for_tests( &mut self, table_name: impl Into<RawIdentifier>, product_type: ProductType, custom_ordering: bool, ) -> RawTableDefBuilderV10<'_>
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>,
source_name: impl Into<RawIdentifier>,
ty: AlgebraicType,
custom_ordering: bool,
) -> AlgebraicTypeRef
pub fn add_algebraic_type( &mut self, scope: impl IntoIterator<Item = RawIdentifier>, source_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 used 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,
source_name: impl Into<RawIdentifier>,
params: ProductType,
)
pub fn add_reducer( &mut self, source_name: impl Into<RawIdentifier>, params: ProductType, )
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,
source_name: impl Into<RawIdentifier>,
params: ProductType,
return_type: AlgebraicType,
)
pub fn add_procedure( &mut self, source_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.
Sourcepub fn add_view(
&mut self,
source_name: impl Into<RawIdentifier>,
index: usize,
is_public: bool,
is_anonymous: bool,
params: ProductType,
return_type: AlgebraicType,
)
pub fn add_view( &mut self, source_name: impl Into<RawIdentifier>, index: usize, is_public: bool, is_anonymous: bool, params: ProductType, return_type: AlgebraicType, )
Add a view to the in-progress module.
Sourcepub fn add_lifecycle_reducer(
&mut self,
lifecycle_spec: Lifecycle,
function_name: impl Into<RawIdentifier>,
params: ProductType,
)
pub fn add_lifecycle_reducer( &mut self, lifecycle_spec: Lifecycle, function_name: impl Into<RawIdentifier>, params: ProductType, )
Add a lifecycle reducer assignment to the module.
The function must be a previously-added reducer.
Sourcepub fn add_schedule(
&mut self,
table: impl Into<RawIdentifier>,
column: impl Into<ColId>,
function: impl Into<RawIdentifier>,
)
pub fn add_schedule( &mut self, table: impl Into<RawIdentifier>, column: impl Into<ColId>, function: impl Into<RawIdentifier>, )
Add a schedule definition to the module.
The function_name should name a reducer or procedure
which accepts one argument, a row of the specified table.
The table must have the appropriate columns for a scheduled table.
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.
pub fn add_explicit_names(&mut self, names: ExplicitNames)
Sourcepub fn set_case_conversion_policy(&mut self, policy: CaseConversionPolicy)
pub fn set_case_conversion_policy(&mut self, policy: CaseConversionPolicy)
Set the case conversion policy for this module.
By default, SpacetimeDB applies SnakeCase conversion to table names,
column names, reducer names, etc. Use CaseConversionPolicy::None to
disable all case conversion (useful for modules with existing data that
was stored under the original naming convention).
Sourcepub fn finish(self) -> RawModuleDefV10
pub fn finish(self) -> RawModuleDefV10
Finish building, consuming the builder and returning the module. The module should be validated before use.
Trait Implementations§
Source§impl Default for RawModuleDefV10Builder
impl Default for RawModuleDefV10Builder
Source§fn default() -> RawModuleDefV10Builder
fn default() -> RawModuleDefV10Builder
Source§impl TypespaceBuilder for RawModuleDefV10Builder
Implement TypespaceBuilder for V10
impl TypespaceBuilder for RawModuleDefV10Builder
Implement TypespaceBuilder for V10
Source§fn add(
&mut self,
typeid: TypeId,
source_name: Option<&'static str>,
make_ty: impl FnOnce(&mut Self) -> AlgebraicType,
) -> AlgebraicType
fn add( &mut self, typeid: TypeId, source_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 RawModuleDefV10Builder
impl RefUnwindSafe for RawModuleDefV10Builder
impl Send for RawModuleDefV10Builder
impl Sync for RawModuleDefV10Builder
impl Unpin for RawModuleDefV10Builder
impl UnsafeUnpin for RawModuleDefV10Builder
impl UnwindSafe for RawModuleDefV10Builder
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