upgrade spacetimedb to v2.0.1
This commit is contained in:
parent
5ebf3f6c05
commit
baab16144b
38 changed files with 481 additions and 1647 deletions
|
|
@ -24,8 +24,6 @@ impl __sdk::InModule for AdvanceGameArgs {
|
|||
type Module = super::RemoteModule;
|
||||
}
|
||||
|
||||
pub struct AdvanceGameCallbackId(__sdk::CallbackId);
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
/// Extension trait for access to the reducer `advance_game`.
|
||||
///
|
||||
|
|
@ -35,73 +33,38 @@ 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<()>;
|
||||
/// Register a callback to run whenever we are notified of an invocation of the reducer `advance_game`.
|
||||
/// and this method provides no way to listen for its completion status.
|
||||
/// /// Use [`advance_game:advance_game_then`] to run a callback after the reducer completes.
|
||||
fn advance_game(&self, game_timer: GameTimer) -> __sdk::Result<()> {
|
||||
self.advance_game_then(game_timer, |_, _| {})
|
||||
}
|
||||
|
||||
/// Request that the remote module invoke the reducer `advance_game` to run as soon as possible,
|
||||
/// registering `callback` to run when we are notified that the reducer completed.
|
||||
///
|
||||
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
|
||||
/// to determine the reducer's status.
|
||||
///
|
||||
/// The returned [`AdvanceGameCallbackId`] can be passed to [`Self::remove_on_advance_game`]
|
||||
/// to cancel the callback.
|
||||
fn on_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 with the `callback`.
|
||||
fn advance_game_then(
|
||||
&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);
|
||||
game_timer: GameTimer,
|
||||
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()>;
|
||||
}
|
||||
|
||||
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 on_advance_game(
|
||||
fn advance_game_then(
|
||||
&self,
|
||||
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 },
|
||||
..
|
||||
},
|
||||
..
|
||||
} = ctx
|
||||
else {
|
||||
unreachable!()
|
||||
};
|
||||
callback(ctx, game_timer)
|
||||
}),
|
||||
))
|
||||
}
|
||||
fn remove_on_advance_game(&self, callback: AdvanceGameCallbackId) {
|
||||
self.imp.remove_on_reducer("advance_game", callback.0)
|
||||
}
|
||||
}
|
||||
game_timer: GameTimer,
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[doc(hidden)]
|
||||
/// Extension trait for setting the call-flags for the reducer `advance_game`.
|
||||
///
|
||||
/// Implemented for [`super::SetReducerFlags`].
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
pub trait set_flags_for_advance_game {
|
||||
/// Set the call-reducer flags for the reducer `advance_game` to `flags`.
|
||||
///
|
||||
/// This type is currently unstable and may be removed without a major version bump.
|
||||
fn advance_game(&self, flags: __ws::CallReducerFlags);
|
||||
}
|
||||
|
||||
impl set_flags_for_advance_game for super::SetReducerFlags {
|
||||
fn advance_game(&self, flags: __ws::CallReducerFlags) {
|
||||
self.imp.set_call_reducer_flags("advance_game", flags);
|
||||
callback: impl FnOnce(&super::ReducerEventContext, Result<Result<(), String>, __sdk::InternalError>)
|
||||
+ Send
|
||||
+ 'static,
|
||||
) -> __sdk::Result<()> {
|
||||
self.imp
|
||||
.invoke_reducer_with_callback(AdvanceGameArgs { game_timer }, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue