🏗️ Split matrix_client.rs to create the matrix_interface module
This commit is contained in:
28
src/matrix_interface/requester.rs
Normal file
28
src/matrix_interface/requester.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use matrix_sdk::Client as MatrixClient;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
|
||||
use super::worker_tasks::{oneshot, LoginStyle, WorkerTask};
|
||||
use crate::base::Room;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Requester {
|
||||
pub matrix_client: Arc<MatrixClient>,
|
||||
pub tx: UnboundedSender<WorkerTask>,
|
||||
pub rooms_receiver: flume::Receiver<Room>,
|
||||
}
|
||||
|
||||
impl Requester {
|
||||
pub fn init(&self) {
|
||||
let (reply, response) = oneshot();
|
||||
self.tx.send(WorkerTask::Init(reply)).unwrap();
|
||||
return response.recv();
|
||||
}
|
||||
|
||||
pub fn login(&self, style: LoginStyle) -> anyhow::Result<()> {
|
||||
let (reply, response) = oneshot();
|
||||
self.tx.send(WorkerTask::Login(style, reply)).unwrap();
|
||||
return response.recv();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user