jong/jong-db/src/db/add_bot_reducer.rs

109 lines
3.6 KiB
Rust
Raw Normal View History

2026-02-08 00:10:10 -08:00
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
2026-02-20 15:36:04 -08:00
use spacetimedb_sdk::__codegen::{
self as __sdk,
__lib,
__sats,
__ws,
};
2026-02-08 00:10:10 -08:00
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct AddBotArgs {
pub lobby_id: u32,
}
impl From<AddBotArgs> for super::Reducer {
fn from(args: AddBotArgs) -> Self {
Self::AddBot {
lobby_id: args.lobby_id,
2026-02-20 15:36:04 -08:00
}
}
2026-02-08 00:10:10 -08:00
}
impl __sdk::InModule for AddBotArgs {
type Module = super::RemoteModule;
}
pub struct AddBotCallbackId(__sdk::CallbackId);
#[allow(non_camel_case_types)]
/// Extension trait for access to the reducer `add_bot`.
///
/// Implemented for [`super::RemoteReducers`].
pub trait add_bot {
/// Request that the remote module invoke the reducer `add_bot` to run as soon as possible.
///
/// 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_add_bot`] callbacks.
2026-02-20 15:36:04 -08:00
fn add_bot(&self, lobby_id: u32,
) -> __sdk::Result<()>;
2026-02-08 00:10:10 -08:00
/// Register a callback to run whenever we are notified of an invocation of the reducer `add_bot`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
/// to determine the reducer's status.
///
/// The returned [`AddBotCallbackId`] can be passed to [`Self::remove_on_add_bot`]
/// to cancel the callback.
2026-02-20 15:36:04 -08:00
fn on_add_bot(&self, callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static) -> AddBotCallbackId;
2026-02-08 00:10:10 -08:00
/// Cancel a callback previously registered by [`Self::on_add_bot`],
/// causing it not to run in the future.
fn remove_on_add_bot(&self, callback: AddBotCallbackId);
}
impl add_bot for super::RemoteReducers {
2026-02-20 15:36:04 -08:00
fn add_bot(&self, lobby_id: u32,
) -> __sdk::Result<()> {
self.imp.call_reducer("add_bot", AddBotArgs { lobby_id, })
2026-02-08 00:10:10 -08:00
}
fn on_add_bot(
&self,
2026-02-20 15:36:04 -08:00
mut callback: impl FnMut(&super::ReducerEventContext, &u32, ) + Send + 'static,
2026-02-08 00:10:10 -08:00
) -> AddBotCallbackId {
AddBotCallbackId(self.imp.on_reducer(
"add_bot",
Box::new(move |ctx: &super::ReducerEventContext| {
#[allow(irrefutable_let_patterns)]
let super::ReducerEventContext {
2026-02-20 15:36:04 -08:00
event: __sdk::ReducerEvent {
reducer: super::Reducer::AddBot {
lobby_id,
2026-02-08 00:10:10 -08:00
},
2026-02-20 15:36:04 -08:00
..
},
2026-02-08 00:10:10 -08:00
..
2026-02-20 15:36:04 -08:00
} = ctx else { unreachable!() };
callback(ctx, lobby_id, )
2026-02-08 00:10:10 -08:00
}),
))
}
fn remove_on_add_bot(&self, callback: AddBotCallbackId) {
self.imp.remove_on_reducer("add_bot", callback.0)
}
}
#[allow(non_camel_case_types)]
#[doc(hidden)]
/// Extension trait for setting the call-flags for the reducer `add_bot`.
///
/// Implemented for [`super::SetReducerFlags`].
///
/// This type is currently unstable and may be removed without a major version bump.
pub trait set_flags_for_add_bot {
/// Set the call-reducer flags for the reducer `add_bot` to `flags`.
///
/// This type is currently unstable and may be removed without a major version bump.
fn add_bot(&self, flags: __ws::CallReducerFlags);
}
impl set_flags_for_add_bot for super::SetReducerFlags {
fn add_bot(&self, flags: __ws::CallReducerFlags) {
self.imp.set_call_reducer_flags("add_bot", flags);
}
}
2026-02-20 15:36:04 -08:00