jong/jong-db/src/db/set_ready_reducer.rs
2026-02-22 00:45:59 -08:00

102 lines
3.7 KiB
Rust

// 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)]
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 {
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.
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.
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 {
fn set_ready(&self, ready: bool) -> __sdk::Result<()> {
self.imp.call_reducer("set_ready", SetReadyArgs { ready })
}
fn on_set_ready(
&self,
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 {
event:
__sdk::ReducerEvent {
reducer: super::Reducer::SetReady { ready },
..
},
..
} = 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);
}
}