Files
SpacetimeDB/crates/cli/tests/snapshots/codegen__codegen_rust.snap

1039 lines
29 KiB
Plaintext

---
source: crates/cli/tests/codegen.rs
expression: outfiles
---
"add_player_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct AddPlayerArgs {
pub name: String,
}
impl Reducer for AddPlayerArgs {
const REDUCER_NAME: &'static str = "add_player";
}
#[allow(unused)]
pub fn add_player(
name: String,
) {
AddPlayerArgs {
name,
} .invoke();
}
#[allow(unused)]
pub fn on_add_player(mut __callback: impl FnMut(&Identity, Option<Address>, &Status, &String) + Send + 'static) -> ReducerCallbackId<AddPlayerArgs>
{
AddPlayerArgs::on_reducer(move |__identity, __addr, __status, __args| {
let AddPlayerArgs {
name,
} = __args;
__callback(
__identity,
__addr,
__status,
name,
);
})
}
#[allow(unused)]
pub fn once_on_add_player(__callback: impl FnOnce(&Identity, Option<Address>, &Status, &String) + Send + 'static) -> ReducerCallbackId<AddPlayerArgs>
{
AddPlayerArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let AddPlayerArgs {
name,
} = __args;
__callback(
__identity,
__addr,
__status,
name,
);
})
}
#[allow(unused)]
pub fn remove_on_add_player(id: ReducerCallbackId<AddPlayerArgs>) {
AddPlayerArgs::remove_on_reducer(id);
}
'''
"add_private_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct AddPrivateArgs {
pub name: String,
}
impl Reducer for AddPrivateArgs {
const REDUCER_NAME: &'static str = "add_private";
}
#[allow(unused)]
pub fn add_private(
name: String,
) {
AddPrivateArgs {
name,
} .invoke();
}
#[allow(unused)]
pub fn on_add_private(mut __callback: impl FnMut(&Identity, Option<Address>, &Status, &String) + Send + 'static) -> ReducerCallbackId<AddPrivateArgs>
{
AddPrivateArgs::on_reducer(move |__identity, __addr, __status, __args| {
let AddPrivateArgs {
name,
} = __args;
__callback(
__identity,
__addr,
__status,
name,
);
})
}
#[allow(unused)]
pub fn once_on_add_private(__callback: impl FnOnce(&Identity, Option<Address>, &Status, &String) + Send + 'static) -> ReducerCallbackId<AddPrivateArgs>
{
AddPrivateArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let AddPrivateArgs {
name,
} = __args;
__callback(
__identity,
__addr,
__status,
name,
);
})
}
#[allow(unused)]
pub fn remove_on_add_private(id: ReducerCallbackId<AddPrivateArgs>) {
AddPrivateArgs::remove_on_reducer(id);
}
'''
"delete_player_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct DeletePlayerArgs {
pub id: u64,
}
impl Reducer for DeletePlayerArgs {
const REDUCER_NAME: &'static str = "delete_player";
}
#[allow(unused)]
pub fn delete_player(
id: u64,
) {
DeletePlayerArgs {
id,
} .invoke();
}
#[allow(unused)]
pub fn on_delete_player(mut __callback: impl FnMut(&Identity, Option<Address>, &Status, &u64) + Send + 'static) -> ReducerCallbackId<DeletePlayerArgs>
{
DeletePlayerArgs::on_reducer(move |__identity, __addr, __status, __args| {
let DeletePlayerArgs {
id,
} = __args;
__callback(
__identity,
__addr,
__status,
id,
);
})
}
#[allow(unused)]
pub fn once_on_delete_player(__callback: impl FnOnce(&Identity, Option<Address>, &Status, &u64) + Send + 'static) -> ReducerCallbackId<DeletePlayerArgs>
{
DeletePlayerArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let DeletePlayerArgs {
id,
} = __args;
__callback(
__identity,
__addr,
__status,
id,
);
})
}
#[allow(unused)]
pub fn remove_on_delete_player(id: ReducerCallbackId<DeletePlayerArgs>) {
DeletePlayerArgs::remove_on_reducer(id);
}
'''
"delete_players_by_name_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct DeletePlayersByNameArgs {
pub name: String,
}
impl Reducer for DeletePlayersByNameArgs {
const REDUCER_NAME: &'static str = "delete_players_by_name";
}
#[allow(unused)]
pub fn delete_players_by_name(
name: String,
) {
DeletePlayersByNameArgs {
name,
} .invoke();
}
#[allow(unused)]
pub fn on_delete_players_by_name(mut __callback: impl FnMut(&Identity, Option<Address>, &Status, &String) + Send + 'static) -> ReducerCallbackId<DeletePlayersByNameArgs>
{
DeletePlayersByNameArgs::on_reducer(move |__identity, __addr, __status, __args| {
let DeletePlayersByNameArgs {
name,
} = __args;
__callback(
__identity,
__addr,
__status,
name,
);
})
}
#[allow(unused)]
pub fn once_on_delete_players_by_name(__callback: impl FnOnce(&Identity, Option<Address>, &Status, &String) + Send + 'static) -> ReducerCallbackId<DeletePlayersByNameArgs>
{
DeletePlayersByNameArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let DeletePlayersByNameArgs {
name,
} = __args;
__callback(
__identity,
__addr,
__status,
name,
);
})
}
#[allow(unused)]
pub fn remove_on_delete_players_by_name(id: ReducerCallbackId<DeletePlayersByNameArgs>) {
DeletePlayersByNameArgs::remove_on_reducer(id);
}
'''
"has_special_stuff.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct HasSpecialStuff {
pub identity: Identity,
pub address: Address,
}
impl TableType for HasSpecialStuff {
const TABLE_NAME: &'static str = "HasSpecialStuff";
type ReducerEvent = super::ReducerEvent;
}
impl HasSpecialStuff {
#[allow(unused)]
pub fn filter_by_identity(identity: Identity) -> TableIter<Self> {
Self::filter(|row| row.identity == identity)
}
#[allow(unused)]
pub fn filter_by_address(address: Address) -> TableIter<Self> {
Self::filter(|row| row.address == address)
}
}
'''
"mod.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
use spacetimedb_sdk::ws_messages::{TableUpdate, TransactionUpdate};
use spacetimedb_sdk::client_cache::{ClientCache, RowCallbackReminders};
use spacetimedb_sdk::identity::Credentials;
use spacetimedb_sdk::callbacks::{DbCallbacks, ReducerCallbacks};
use spacetimedb_sdk::reducer::AnyReducerEvent;
use spacetimedb_sdk::global_connection::with_connection_mut;
use spacetimedb_sdk::spacetime_module::SpacetimeModule;
use std::sync::Arc;
pub mod namespace.test_c;
pub mod test_b;
pub mod namespace.test_f;
pub mod has_special_stuff;
pub mod pk_multi_identity;
pub mod point;
pub mod private;
pub mod repeating_test_arg;
pub mod test_a;
pub mod test_d;
pub mod test_e;
pub mod add_player_reducer;
pub mod add_private_reducer;
pub mod delete_player_reducer;
pub mod delete_players_by_name_reducer;
pub mod query_private_reducer;
pub mod repeating_test_reducer;
pub mod test_reducer;
pub use namespace.test_c::*;
pub use test_b::*;
pub use namespace.test_f::*;
pub use has_special_stuff::*;
pub use pk_multi_identity::*;
pub use point::*;
pub use private::*;
pub use repeating_test_arg::*;
pub use test_a::*;
pub use test_d::*;
pub use test_e::*;
pub use add_player_reducer::*;
pub use add_private_reducer::*;
pub use delete_player_reducer::*;
pub use delete_players_by_name_reducer::*;
pub use query_private_reducer::*;
pub use repeating_test_reducer::*;
pub use test_reducer::*;
#[allow(unused)]
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum ReducerEvent {
AddPlayer(add_player_reducer::AddPlayerArgs),
AddPrivate(add_private_reducer::AddPrivateArgs),
DeletePlayer(delete_player_reducer::DeletePlayerArgs),
DeletePlayersByName(delete_players_by_name_reducer::DeletePlayersByNameArgs),
QueryPrivate(query_private_reducer::QueryPrivateArgs),
RepeatingTest(repeating_test_reducer::RepeatingTestArgs),
Test(test_reducer::TestArgs),
}
#[allow(unused)]
pub struct Module;
impl SpacetimeModule for Module {
fn handle_table_update(&self, table_update: TableUpdate, client_cache: &mut ClientCache, callbacks: &mut RowCallbackReminders) {
let table_name = &table_update.table_name[..];
match table_name {
"HasSpecialStuff" => client_cache.handle_table_update_no_primary_key::<has_special_stuff::HasSpecialStuff>(callbacks, table_update),
"PkMultiIdentity" => client_cache.handle_table_update_with_primary_key::<pk_multi_identity::PkMultiIdentity>(callbacks, table_update),
"Point" => client_cache.handle_table_update_no_primary_key::<point::Point>(callbacks, table_update),
"Private" => client_cache.handle_table_update_no_primary_key::<private::Private>(callbacks, table_update),
"RepeatingTestArg" => client_cache.handle_table_update_with_primary_key::<repeating_test_arg::RepeatingTestArg>(callbacks, table_update),
"TestA" => client_cache.handle_table_update_no_primary_key::<test_a::TestA>(callbacks, table_update),
"TestD" => client_cache.handle_table_update_no_primary_key::<test_d::TestD>(callbacks, table_update),
"TestE" => client_cache.handle_table_update_with_primary_key::<test_e::TestE>(callbacks, table_update),
_ => spacetimedb_sdk::log::error!("TableRowOperation on unknown table {:?}", table_name),
}
}
fn invoke_row_callbacks(&self, reminders: &mut RowCallbackReminders, worker: &mut DbCallbacks, reducer_event: Option<Arc<AnyReducerEvent>>, state: &Arc<ClientCache>) {
reminders.invoke_callbacks::<has_special_stuff::HasSpecialStuff>(worker, &reducer_event, state);
reminders.invoke_callbacks::<pk_multi_identity::PkMultiIdentity>(worker, &reducer_event, state);
reminders.invoke_callbacks::<point::Point>(worker, &reducer_event, state);
reminders.invoke_callbacks::<private::Private>(worker, &reducer_event, state);
reminders.invoke_callbacks::<repeating_test_arg::RepeatingTestArg>(worker, &reducer_event, state);
reminders.invoke_callbacks::<test_a::TestA>(worker, &reducer_event, state);
reminders.invoke_callbacks::<test_d::TestD>(worker, &reducer_event, state);
reminders.invoke_callbacks::<test_e::TestE>(worker, &reducer_event, state);
}
fn handle_event(&self, event: TransactionUpdate, _reducer_callbacks: &mut ReducerCallbacks, _state: Arc<ClientCache>) -> Option<Arc<AnyReducerEvent>> {
let reducer_call = &event.reducer_call;
#[allow(clippy::match_single_binding)]
match &reducer_call.reducer_name[..] {
"add_player" => _reducer_callbacks.handle_event_of_type::<add_player_reducer::AddPlayerArgs, ReducerEvent>(event, _state, ReducerEvent::AddPlayer),
"add_private" => _reducer_callbacks.handle_event_of_type::<add_private_reducer::AddPrivateArgs, ReducerEvent>(event, _state, ReducerEvent::AddPrivate),
"delete_player" => _reducer_callbacks.handle_event_of_type::<delete_player_reducer::DeletePlayerArgs, ReducerEvent>(event, _state, ReducerEvent::DeletePlayer),
"delete_players_by_name" => _reducer_callbacks.handle_event_of_type::<delete_players_by_name_reducer::DeletePlayersByNameArgs, ReducerEvent>(event, _state, ReducerEvent::DeletePlayersByName),
"query_private" => _reducer_callbacks.handle_event_of_type::<query_private_reducer::QueryPrivateArgs, ReducerEvent>(event, _state, ReducerEvent::QueryPrivate),
"repeating_test" => _reducer_callbacks.handle_event_of_type::<repeating_test_reducer::RepeatingTestArgs, ReducerEvent>(event, _state, ReducerEvent::RepeatingTest),
"test" => _reducer_callbacks.handle_event_of_type::<test_reducer::TestArgs, ReducerEvent>(event, _state, ReducerEvent::Test),
unknown => { spacetimedb_sdk::log::error!("Event on an unknown reducer: {:?}", unknown); None }
}
}
fn handle_resubscribe(&self, new_subs: TableUpdate, client_cache: &mut ClientCache, callbacks: &mut RowCallbackReminders) {
let table_name = &new_subs.table_name[..];
match table_name {
"HasSpecialStuff" => client_cache.handle_resubscribe_for_type::<has_special_stuff::HasSpecialStuff>(callbacks, new_subs),
"PkMultiIdentity" => client_cache.handle_resubscribe_for_type::<pk_multi_identity::PkMultiIdentity>(callbacks, new_subs),
"Point" => client_cache.handle_resubscribe_for_type::<point::Point>(callbacks, new_subs),
"Private" => client_cache.handle_resubscribe_for_type::<private::Private>(callbacks, new_subs),
"RepeatingTestArg" => client_cache.handle_resubscribe_for_type::<repeating_test_arg::RepeatingTestArg>(callbacks, new_subs),
"TestA" => client_cache.handle_resubscribe_for_type::<test_a::TestA>(callbacks, new_subs),
"TestD" => client_cache.handle_resubscribe_for_type::<test_d::TestD>(callbacks, new_subs),
"TestE" => client_cache.handle_resubscribe_for_type::<test_e::TestE>(callbacks, new_subs),
_ => spacetimedb_sdk::log::error!("TableRowOperation on unknown table {:?}", table_name),
}
}
}
/// Connect to a database named `db_name` accessible over the internet at the URI `spacetimedb_uri`.
///
/// If `credentials` are supplied, they will be passed to the new connection to
/// identify and authenticate the user. Otherwise, a set of `Credentials` will be
/// generated by the server.
pub fn connect<IntoUri>(spacetimedb_uri: IntoUri, db_name: &str, credentials: Option<Credentials>) -> Result<()>
where
IntoUri: TryInto<spacetimedb_sdk::http::Uri>,
<IntoUri as TryInto<spacetimedb_sdk::http::Uri>>::Error: std::error::Error + Send + Sync + 'static,
{
with_connection_mut(|connection| {
connection.connect(spacetimedb_uri, db_name, credentials, Arc::new(Module))?;
Ok(())
})
}
'''
"namespace_test_c.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum Namespace.testC {
Foo,
Bar,
}
'''
"namespace_test_f.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub enum Namespace.testF {
Foo,
Bar,
Baz(String),
}
'''
"pk_multi_identity.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct PkMultiIdentity {
pub id: u32,
pub other: u32,
}
impl TableType for PkMultiIdentity {
const TABLE_NAME: &'static str = "PkMultiIdentity";
type ReducerEvent = super::ReducerEvent;
}
impl TableWithPrimaryKey for PkMultiIdentity {
type PrimaryKey = u32;
fn primary_key(&self) -> &Self::PrimaryKey {
&self.id
}
}
impl PkMultiIdentity {
#[allow(unused)]
pub fn filter_by_id(id: u32) -> TableIter<Self> {
Self::filter(|row| row.id == id)
}
#[allow(unused)]
pub fn find_by_id(id: u32) -> Option<Self> {
Self::find(|row| row.id == id)
}
#[allow(unused)]
pub fn filter_by_other(other: u32) -> TableIter<Self> {
Self::filter(|row| row.other == other)
}
#[allow(unused)]
pub fn find_by_other(other: u32) -> Option<Self> {
Self::find(|row| row.other == other)
}
}
'''
"point.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct Point {
pub x: i64,
pub y: i64,
}
impl TableType for Point {
const TABLE_NAME: &'static str = "Point";
type ReducerEvent = super::ReducerEvent;
}
impl Point {
#[allow(unused)]
pub fn filter_by_x(x: i64) -> TableIter<Self> {
Self::filter(|row| row.x == x)
}
#[allow(unused)]
pub fn filter_by_y(y: i64) -> TableIter<Self> {
Self::filter(|row| row.y == y)
}
}
'''
"private.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct Private {
pub name: String,
}
impl TableType for Private {
const TABLE_NAME: &'static str = "Private";
type ReducerEvent = super::ReducerEvent;
}
impl Private {
#[allow(unused)]
pub fn filter_by_name(name: String) -> TableIter<Self> {
Self::filter(|row| row.name == name)
}
}
'''
"query_private_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct QueryPrivateArgs {
}
impl Reducer for QueryPrivateArgs {
const REDUCER_NAME: &'static str = "query_private";
}
#[allow(unused)]
pub fn query_private(
) {
QueryPrivateArgs {
}.invoke();
}
#[allow(unused)]
pub fn on_query_private(mut __callback: impl FnMut(&Identity, Option<Address>, &Status) + Send + 'static) -> ReducerCallbackId<QueryPrivateArgs>
{
QueryPrivateArgs::on_reducer(move |__identity, __addr, __status, __args| {
let QueryPrivateArgs {
} = __args;
__callback(
__identity,
__addr,
__status,
);
})
}
#[allow(unused)]
pub fn once_on_query_private(__callback: impl FnOnce(&Identity, Option<Address>, &Status) + Send + 'static) -> ReducerCallbackId<QueryPrivateArgs>
{
QueryPrivateArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let QueryPrivateArgs {
} = __args;
__callback(
__identity,
__addr,
__status,
);
})
}
#[allow(unused)]
pub fn remove_on_query_private(id: ReducerCallbackId<QueryPrivateArgs>) {
QueryPrivateArgs::remove_on_reducer(id);
}
'''
"repeating_test_arg.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct RepeatingTestArg {
pub prev_time: u64,
pub scheduled_id: u64,
pub scheduled_at: ScheduleAt,
}
impl TableType for RepeatingTestArg {
const TABLE_NAME: &'static str = "RepeatingTestArg";
type ReducerEvent = super::ReducerEvent;
}
impl TableWithPrimaryKey for RepeatingTestArg {
type PrimaryKey = u64;
fn primary_key(&self) -> &Self::PrimaryKey {
&self.scheduled_id
}
}
impl RepeatingTestArg {
#[allow(unused)]
pub fn filter_by_prev_time(prev_time: u64) -> TableIter<Self> {
Self::filter(|row| row.prev_time == prev_time)
}
#[allow(unused)]
pub fn filter_by_scheduled_id(scheduled_id: u64) -> TableIter<Self> {
Self::filter(|row| row.scheduled_id == scheduled_id)
}
#[allow(unused)]
pub fn find_by_scheduled_id(scheduled_id: u64) -> Option<Self> {
Self::find(|row| row.scheduled_id == scheduled_id)
}
}
'''
"repeating_test_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
use super::repeating_test_arg::RepeatingTestArg;
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct RepeatingTestArgs {
pub arg: RepeatingTestArg,
}
impl Reducer for RepeatingTestArgs {
const REDUCER_NAME: &'static str = "repeating_test";
}
#[allow(unused)]
pub fn repeating_test(
arg: RepeatingTestArg,
) {
RepeatingTestArgs {
arg,
} .invoke();
}
#[allow(unused)]
pub fn on_repeating_test(mut __callback: impl FnMut(&Identity, Option<Address>, &Status, &RepeatingTestArg) + Send + 'static) -> ReducerCallbackId<RepeatingTestArgs>
{
RepeatingTestArgs::on_reducer(move |__identity, __addr, __status, __args| {
let RepeatingTestArgs {
arg,
} = __args;
__callback(
__identity,
__addr,
__status,
arg,
);
})
}
#[allow(unused)]
pub fn once_on_repeating_test(__callback: impl FnOnce(&Identity, Option<Address>, &Status, &RepeatingTestArg) + Send + 'static) -> ReducerCallbackId<RepeatingTestArgs>
{
RepeatingTestArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let RepeatingTestArgs {
arg,
} = __args;
__callback(
__identity,
__addr,
__status,
arg,
);
})
}
#[allow(unused)]
pub fn remove_on_repeating_test(id: ReducerCallbackId<RepeatingTestArgs>) {
RepeatingTestArgs::remove_on_reducer(id);
}
'''
"test_a.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct TestA {
pub x: u32,
pub y: u32,
pub z: String,
}
impl TableType for TestA {
const TABLE_NAME: &'static str = "TestA";
type ReducerEvent = super::ReducerEvent;
}
impl TestA {
#[allow(unused)]
pub fn filter_by_x(x: u32) -> TableIter<Self> {
Self::filter(|row| row.x == x)
}
#[allow(unused)]
pub fn filter_by_y(y: u32) -> TableIter<Self> {
Self::filter(|row| row.y == y)
}
#[allow(unused)]
pub fn filter_by_z(z: String) -> TableIter<Self> {
Self::filter(|row| row.z == z)
}
}
'''
"test_b.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct TestB {
pub foo: String,
}
'''
"test_d.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
use super::namespace.test_c::Namespace.testC;
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct TestD {
pub test_c: Option::<Namespace.testC>,
}
impl TableType for TestD {
const TABLE_NAME: &'static str = "TestD";
type ReducerEvent = super::ReducerEvent;
}
impl TestD {
}
'''
"test_e.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct TestE {
pub id: u64,
pub name: String,
}
impl TableType for TestE {
const TABLE_NAME: &'static str = "TestE";
type ReducerEvent = super::ReducerEvent;
}
impl TableWithPrimaryKey for TestE {
type PrimaryKey = u64;
fn primary_key(&self) -> &Self::PrimaryKey {
&self.id
}
}
impl TestE {
#[allow(unused)]
pub fn filter_by_id(id: u64) -> TableIter<Self> {
Self::filter(|row| row.id == id)
}
#[allow(unused)]
pub fn find_by_id(id: u64) -> Option<Self> {
Self::find(|row| row.id == id)
}
#[allow(unused)]
pub fn filter_by_name(name: String) -> TableIter<Self> {
Self::filter(|row| row.name == name)
}
}
'''
"test_reducer.rs" = '''
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
#![allow(unused_imports)]use spacetimedb_sdk::{
Address, ScheduleAt,
sats::{ser::Serialize, de::Deserialize, i256, u256},
table::{TableType, TableIter, TableWithPrimaryKey},
reducer::{Reducer, ReducerCallbackId, Status},
identity::Identity,
spacetimedb_lib,
anyhow::{Result, anyhow},
};
use super::namespace.test_c::Namespace.testC;
use super::namespace.test_f::Namespace.testF;
use super::test_a::TestA;
use super::test_b::TestB;
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug)]
pub struct TestArgs {
pub arg: TestA,
pub arg_2: TestB,
pub arg_3: Namespace.testC,
pub arg_4: Namespace.testF,
}
impl Reducer for TestArgs {
const REDUCER_NAME: &'static str = "test";
}
#[allow(unused)]
pub fn test(
arg: TestA,
arg_2: TestB,
arg_3: Namespace.testC,
arg_4: Namespace.testF,
) {
TestArgs {
arg,
arg_2,
arg_3,
arg_4,
} .invoke();
}
#[allow(unused)]
pub fn on_test(mut __callback: impl FnMut(&Identity, Option<Address>, &Status, &TestA, &TestB, &Namespace.testC, &Namespace.testF) + Send + 'static) -> ReducerCallbackId<TestArgs>
{
TestArgs::on_reducer(move |__identity, __addr, __status, __args| {
let TestArgs {
arg,
arg_2,
arg_3,
arg_4,
} = __args;
__callback(
__identity,
__addr,
__status,
arg,
arg_2,
arg_3,
arg_4,
);
})
}
#[allow(unused)]
pub fn once_on_test(__callback: impl FnOnce(&Identity, Option<Address>, &Status, &TestA, &TestB, &Namespace.testC, &Namespace.testF) + Send + 'static) -> ReducerCallbackId<TestArgs>
{
TestArgs::once_on_reducer(move |__identity, __addr, __status, __args| {
let TestArgs {
arg,
arg_2,
arg_3,
arg_4,
} = __args;
__callback(
__identity,
__addr,
__status,
arg,
arg_2,
arg_3,
arg_4,
);
})
}
#[allow(unused)]
pub fn remove_on_test(id: ReducerCallbackId<TestArgs>) {
TestArgs::remove_on_reducer(id);
}
'''