jong/jong-db/src/db/set_ready_reducer.rs

109 lines
3.7 KiB
Rust
Raw Normal View History

// 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,
};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub(super) struct SetReadyArgs {
pub ready: bool,
}
impl From<SetReadyArgs> for super::Reducer {
fn from(args: SetReadyArgs) -> Self {
2026-02-20 15:36:04 -08:00
Self::SetReady {
ready: args.ready,
}
}
}
impl __sdk::InModule for SetReadyArgs {
type Module = super::RemoteModule;
}
pub struct SetReadyCallbackId(__sdk::CallbackId);
#[allow(non_camel_case_types)]
/// Extension trait for access to the reducer `set_ready`.
///
/// Implemented for [`super::RemoteReducers`].
pub trait set_ready {
/// Request that the remote module invoke the reducer `set_ready` 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_set_ready`] callbacks.
2026-02-20 15:36:04 -08:00
fn set_ready(&self, ready: bool,
) -> __sdk::Result<()>;
/// Register a callback to run whenever we are notified of an invocation of the reducer `set_ready`.
///
/// Callbacks should inspect the [`__sdk::ReducerEvent`] contained in the [`super::ReducerEventContext`]
/// to determine the reducer's status.
///
/// The returned [`SetReadyCallbackId`] can be passed to [`Self::remove_on_set_ready`]
/// to cancel the callback.
2026-02-20 15:36:04 -08:00
fn on_set_ready(&self, callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static) -> SetReadyCallbackId;
/// Cancel a callback previously registered by [`Self::on_set_ready`],
/// causing it not to run in the future.
fn remove_on_set_ready(&self, callback: SetReadyCallbackId);
}
impl set_ready for super::RemoteReducers {
2026-02-20 15:36:04 -08:00
fn set_ready(&self, ready: bool,
) -> __sdk::Result<()> {
self.imp.call_reducer("set_ready", SetReadyArgs { ready, })
}
fn on_set_ready(
&self,
2026-02-20 15:36:04 -08:00
mut callback: impl FnMut(&super::ReducerEventContext, &bool, ) + Send + 'static,
) -> SetReadyCallbackId {
SetReadyCallbackId(self.imp.on_reducer(
"set_ready",
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::SetReady {
ready,
},
2026-02-20 15:36:04 -08:00
..
},
..
2026-02-20 15:36:04 -08:00
} = ctx else { unreachable!() };
callback(ctx, ready, )
}),
))
}
fn remove_on_set_ready(&self, callback: SetReadyCallbackId) {
self.imp.remove_on_reducer("set_ready", callback.0)
}
}
#[allow(non_camel_case_types)]
#[doc(hidden)]
/// Extension trait for setting the call-flags for the reducer `set_ready`.
///
/// Implemented for [`super::SetReducerFlags`].
///
/// This type is currently unstable and may be removed without a major version bump.
pub trait set_flags_for_set_ready {
/// Set the call-reducer flags for the reducer `set_ready` to `flags`.
///
/// This type is currently unstable and may be removed without a major version bump.
fn set_ready(&self, flags: __ws::CallReducerFlags);
}
impl set_flags_for_set_ready for super::SetReducerFlags {
fn set_ready(&self, flags: __ws::CallReducerFlags) {
self.imp.set_call_reducer_flags("set_ready", flags);
}
}
2026-02-20 15:36:04 -08:00