Moved client to separate thread.
All checks were successful
MoreThanText/morethantext/pipeline/head This commit looks good
All checks were successful
MoreThanText/morethantext/pipeline/head This commit looks good
This commit is contained in:
27
src/lib.rs
27
src/lib.rs
@ -1,31 +1,28 @@
|
||||
mod client;
|
||||
mod field;
|
||||
|
||||
use client::{Client, Reply, Request};
|
||||
use field::Field;
|
||||
|
||||
pub struct Reply;
|
||||
|
||||
impl Reply {
|
||||
pub fn get_session(&self) -> String {
|
||||
"id".to_string()
|
||||
}
|
||||
|
||||
pub fn get_content(&self) -> String {
|
||||
"Something goes here.".to_string()
|
||||
}
|
||||
}
|
||||
use std::sync::mpsc::{channel, Sender};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct MoreThanText;
|
||||
pub struct MoreThanText {
|
||||
tx: Sender<Request>,
|
||||
}
|
||||
|
||||
impl MoreThanText {
|
||||
pub fn new() -> Self {
|
||||
Self {}
|
||||
let tx = Client::start();
|
||||
Self { tx: tx }
|
||||
}
|
||||
|
||||
pub fn request<F>(&self, _session: Option<F>) -> Reply
|
||||
where
|
||||
F: Into<Field>,
|
||||
{
|
||||
Reply {}
|
||||
let (tx, rx) = channel();
|
||||
let req = Request::new(tx);
|
||||
self.tx.send(req).unwrap();
|
||||
rx.recv().unwrap()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user