use bevy_ecs::prelude::Message;
use spacetimedb_sdk::{
__codegen::{AbstractEventContext, InModule, SpacetimeModule},
Error, Identity,
};
pub type RowEvent<T> =
<<<T as InModule>::Module as SpacetimeModule>::EventContext as AbstractEventContext>::Event;
#[derive(Message, Debug)]
pub struct StdbConnectedMessage {
pub identity: Identity,
pub access_token: String,
}
#[derive(Message, Debug)]
pub struct StdbDisconnectedMessage {
pub err: Option<Error>,
}
#[derive(Message, Debug)]
pub struct StdbConnectErrorMessage {
pub err: Error,
}
#[derive(Message, Clone, Debug)]
pub struct StdbSubscriptionAppliedMessage<K> {
pub key: K,
}
impl<K: PartialEq> StdbSubscriptionAppliedMessage<K> {
pub fn is(&self, key: &K) -> bool {
&self.key == key
}
}
#[derive(Message, Clone, Debug)]
pub struct StdbSubscriptionErrorMessage<K> {
pub key: K,
pub err: Error,
}
impl<K: PartialEq> StdbSubscriptionErrorMessage<K> {
pub fn is(&self, key: &K) -> bool {
&self.key == key
}
}
#[derive(Message, Debug)]
pub struct InsertMessage<T>
where
T: InModule,
RowEvent<T>: Send + Sync,
{
pub event: RowEvent<T>,
pub row: T,
}
#[derive(Message, Debug)]
pub struct DeleteMessage<T>
where
T: InModule,
RowEvent<T>: Send + Sync,
{
pub event: RowEvent<T>,
pub row: T,
}
#[derive(Message, Debug)]
pub struct UpdateMessage<T>
where
T: InModule,
RowEvent<T>: Send + Sync,
{
pub event: RowEvent<T>,
pub old: T,
pub new: T,
}
#[derive(Message, Debug)]
pub struct InsertUpdateMessage<T>
where
T: InModule,
RowEvent<T>: Send + Sync,
{
pub event: RowEvent<T>,
pub old: Option<T>,
pub new: T,
}