| 1234567891011121314151617181920212223242526 |
- use tokio::sync::{mpsc, oneshot};
- #[derive(Debug)]
- pub enum TgManagerCommand {
- Get {
- user_id: String,
- reply_to: oneshot::Sender<String>,
- },
- }
- pub async fn user_manager(rx: &mut mpsc::Receiver<TgManagerCommand>) {
- log::info!("Request came");
- while let Some(cmd) = rx.recv().await {
- use TgManagerCommand::*;
- log::info!("Command received");
- match cmd {
- Get { user_id, reply_to } => {
- log::info!("{}", format!("Get command found, sending {}", user_id));
- reply_to
- .send(format!("You've requested {}", user_id))
- .unwrap();
- }
- }
- }
- }
|