mpsc_bot/src/track.rs

53 lines
1.0 KiB
Rust

use std::{
collections::HashMap,
sync::{atomic::AtomicBool, Arc},
};
use serenity::{
futures::lock::Mutex,
model::id::{ChannelId, MessageId},
prelude::TypeMapKey,
};
pub mod err_strs {
pub const EXPECTED_SOURCE_CHANNEL: &str = "Expected SourceChannel in TypeMap";
pub const EXPECTED_TARGET_CHANNEL: &str = "Expected TargetChannel in TypeMap";
pub const EXPECTED_ACTIVE: &str = "Expected Active in TypeMap";
}
pub struct Active;
impl TypeMapKey for Active {
type Value = Arc<AtomicBool>;
}
pub struct InfoSent;
impl TypeMapKey for InfoSent {
type Value = Arc<Mutex<Vec<(ChannelId, MessageId)>>>;
}
pub struct Sent;
impl TypeMapKey for Sent {
type Value = Arc<Mutex<HashMap<(ChannelId, MessageId), (ChannelId, MessageId)>>>;
}
pub struct SourceChannel;
impl TypeMapKey for SourceChannel {
type Value = Arc<Mutex<Option<ChannelId>>>;
}
pub struct TargetChannel;
impl TypeMapKey for TargetChannel {
type Value = Arc<Mutex<Option<ChannelId>>>;
}
pub struct Weave;
impl TypeMapKey for Weave {
type Value = Arc<AtomicBool>;
}