🏗️ Split matrix_client.rs to create the matrix_interface module

This commit is contained in:
2023-12-17 11:54:21 +01:00
parent ae8dba86f6
commit 513b05ddb3
7 changed files with 147 additions and 129 deletions

View 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();
}
}