This commit is contained in:
Tao Tien 2026-02-22 00:08:02 -08:00
parent d1446309c4
commit d7b4221727
41 changed files with 893 additions and 1673 deletions

View file

@ -2,13 +2,7 @@
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@ -20,8 +14,8 @@ impl From<JoinOrCreateLobbyArgs> for super::Reducer {
fn from(args: JoinOrCreateLobbyArgs) -> Self {
Self::JoinOrCreateLobby {
lobby_id: args.lobby_id,
}
}
}
}
}
impl __sdk::InModule for JoinOrCreateLobbyArgs {
@ -40,8 +34,7 @@ pub trait join_or_create_lobby {
/// This method returns immediately, and errors only if we are unable to send the request.
/// The reducer will run asynchronously in the future,
/// and its status can be observed by listening for [`Self::on_join_or_create_lobby`] callbacks.
fn join_or_create_lobby(&self, lobby_id: u32,
) -> __sdk::Result<()>;
fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `join_or_create_lobby`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
@ -49,40 +42,46 @@ pub trait join_or_create_lobby {
///
/// The returned [`JoinOrCreateLobbyCallbackId`] can be passed to [`Self::remove_on_join_or_create_lobby`]
/// to cancel the callback.
fn on_join_or_create_lobby(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> JoinOrCreateLobbyCallbackId;
fn on_join_or_create_lobby(
&self,
callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> JoinOrCreateLobbyCallbackId;
/// Cancel a callback previously registered by [`Self::on_join_or_create_lobby`],
/// causing it not to run in the future.
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId);
}
impl join_or_create_lobby for super::RemoteReducers {
fn join_or_create_lobby(&self, lobby_id: u32,
) -> __sdk::Result<()> {
self.imp.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id, })
fn join_or_create_lobby(&self, lobby_id: u32) -> __sdk::Result<()> {
self.imp
.call_reducer("join_or_create_lobby", JoinOrCreateLobbyArgs { lobby_id })
}
fn on_join_or_create_lobby(
&self,
mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static,
mut callback: impl FnMut(&super::ReducerEventContext, &u32) + Send + 'static,
) -> JoinOrCreateLobbyCallbackId {
JoinOrCreateLobbyCallbackId(self.imp.on_reducer(
"join_or_create_lobby",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
event: __sdk::ReducerEvent {
reducer: super::Reducer::JoinOrCreateLobby {
lobby_id,
event:
__sdk::ReducerEvent {
reducer: super::Reducer::JoinOrCreateLobby { lobby_id },
..
},
..
},
..
} = ctx else { unreachable!() };
callback(ctx, lobby_id, )
} = ctx
else {
unreachable!()
};
callback(ctx, lobby_id)
}),
))
}
fn remove_on_join_or_create_lobby(&self, callback: JoinOrCreateLobbyCallbackId) {
self.imp.remove_on_reducer("join_or_create_lobby", callback.0)
self.imp
.remove_on_reducer("join_or_create_lobby", callback.0)
}
}
@ -102,7 +101,7 @@ pub trait set_flags_for_join_or_create_lobby {
impl set_flags_for_join_or_create_lobby for super::SetReducerFlags {
fn join_or_create_lobby(&self, flags: __ws::CallReducerFlags) {
self.imp.set_call_reducer_flags("join_or_create_lobby", flags);
self.imp
.set_call_reducer_flags("join_or_create_lobby", flags);
}
}