codegen
This commit is contained in:
parent
d1446309c4
commit
d7b4221727
41 changed files with 893 additions and 1673 deletions
|
|
@ -2,12 +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};
|
||||
|
||||
use super::game_timer_type::GameTimer;
|
||||
|
||||
|
|
@ -21,8 +16,8 @@ impl From<AdvanceGameArgs> for super::Reducer {
|
|||
fn from(args: AdvanceGameArgs) -> Self {
|
||||
Self::AdvanceGame {
|
||||
game_timer: args.game_timer,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl __sdk::InModule for AdvanceGameArgs {
|
||||
|
|
@ -41,8 +36,7 @@ pub trait advance_game {
|
|||
/// 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_advance_game`] callbacks.
|
||||
fn advance_game(&self, game_timer: GameTimer,
|
||||
) -> __sdk::Result<()>;
|
||||
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `advance_game`.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
|
|
@ -50,35 +44,40 @@ pub trait advance_game {
|
|||
///
|
||||
/// The returned [`AdvanceGameCallbackId`] can be passed to [`Self::remove_on_advance_game`]
|
||||
/// to cancel the callback.
|
||||
fn on_advance_game(&self, callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static) -> AdvanceGameCallbackId;
|
||||
fn on_advance_game(
|
||||
&self,
|
||||
callback: impl FnMut(&super::ReducerEventContext, &GameTimer) + Send + 'static,
|
||||
) -> AdvanceGameCallbackId;
|
||||
/// Cancel a callback previously registered by [`Self::on_advance_game`],
|
||||
/// causing it not to run in the future.
|
||||
fn remove_on_advance_game(&self, callback: AdvanceGameCallbackId);
|
||||
}
|
||||
|
||||
impl advance_game for super::RemoteReducers {
|
||||
fn advance_game(&self, game_timer: GameTimer,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp.call_reducer("advance_game", AdvanceGameArgs { game_timer, })
|
||||
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.call_reducer("advance_game", AdvanceGameArgs { game_timer })
|
||||
}
|
||||
fn on_advance_game(
|
||||
&self,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer, ) + Send + 'static,
|
||||
mut callback: impl FnMut(&super::ReducerEventContext, &GameTimer) + Send + 'static,
|
||||
) -> AdvanceGameCallbackId {
|
||||
AdvanceGameCallbackId(self.imp.on_reducer(
|
||||
"advance_game",
|
||||
Box::new(move |ctx: &super::ReducerEventContext| {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
let super::ReducerEventContext {
|
||||
event: __sdk::ReducerEvent {
|
||||
reducer: super::Reducer::AdvanceGame {
|
||||
game_timer,
|
||||
event:
|
||||
__sdk::ReducerEvent {
|
||||
reducer: super::Reducer::AdvanceGame { game_timer },
|
||||
..
|
||||
},
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx else { unreachable!() };
|
||||
callback(ctx, game_timer, )
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, game_timer)
|
||||
}),
|
||||
))
|
||||
}
|
||||
|
|
@ -106,4 +105,3 @@ impl set_flags_for_advance_game for super::SetReducerFlags {
|
|||
self.imp.set_call_reducer_flags("advance_game", flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue