wagie start
This commit is contained in:
parent
f90866be8a
commit
07b63963d5
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -1131,9 +1131,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.12"
|
version = "0.5.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95"
|
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
|
@ -2090,6 +2090,7 @@ dependencies = [
|
||||||
name = "hoot-app"
|
name = "hoot-app"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"crossbeam-channel",
|
||||||
"eframe",
|
"eframe",
|
||||||
"egui_extras",
|
"egui_extras",
|
||||||
"egui_tabs",
|
"egui_tabs",
|
||||||
|
@ -4361,7 +4362,9 @@ dependencies = [
|
||||||
"bytes",
|
"bytes",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
|
"signal-hook-registry",
|
||||||
"socket2 0.5.7",
|
"socket2 0.5.7",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
|
|
|
@ -28,7 +28,8 @@ rand = "0.8.5"
|
||||||
nostr = { version = "0.32.1", features = ["std", "nip59"] }
|
nostr = { version = "0.32.1", features = ["std", "nip59"] }
|
||||||
serde = "1.0.204"
|
serde = "1.0.204"
|
||||||
serde_json = "1.0.121"
|
serde_json = "1.0.121"
|
||||||
tokio = "1.41.1"
|
tokio = { version = "1.41.1", features = ["full"] }
|
||||||
|
crossbeam-channel = "0.5.13"
|
||||||
|
|
||||||
[target.'cfg(target_os = "macos")'.dependencies]
|
[target.'cfg(target_os = "macos")'.dependencies]
|
||||||
security-framework = "3.0.0"
|
security-framework = "3.0.0"
|
||||||
|
|
|
@ -13,6 +13,7 @@ mod keystorage;
|
||||||
mod mail_event;
|
mod mail_event;
|
||||||
mod relay;
|
mod relay;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
mod wagie;
|
||||||
|
|
||||||
fn main() -> Result<(), eframe::Error> {
|
fn main() -> Result<(), eframe::Error> {
|
||||||
let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); // add log files in prod one day
|
let (non_blocking, _guard) = tracing_appender::non_blocking(std::io::stdout()); // add log files in prod one day
|
||||||
|
|
59
src/wagie/mod.rs
Normal file
59
src/wagie/mod.rs
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Command {
|
||||||
|
Decrypt { content: String, pk: String }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum Response {
|
||||||
|
DecryptedText
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Boss {
|
||||||
|
from_wagie: crossbeam_channel::Receiver<Response>,
|
||||||
|
to_wagie: mpsc::UnboundedSender<Command>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Boss {
|
||||||
|
pub fn init() -> Self {
|
||||||
|
let (from_wagie_sender, from_wagie_receiver) = crossbeam_channel::unbounded::<Response>();
|
||||||
|
let (to_wagie_sender, to_wagie_receiver) = mpsc::unbounded_channel::<Command>();
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut wagie = Wagie::init(to_wagie_receiver, from_wagie_sender);
|
||||||
|
wagie.run().await;
|
||||||
|
});
|
||||||
|
|
||||||
|
Self {
|
||||||
|
from_wagie: from_wagie_receiver,
|
||||||
|
to_wagie: to_wagie_sender,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Wagie {
|
||||||
|
to_boss: crossbeam_channel::Sender<Response>,
|
||||||
|
from_boss: mpsc::UnboundedReceiver<Command>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Wagie {
|
||||||
|
pub fn init(from_boss: mpsc::UnboundedReceiver<Command>, to_boss: crossbeam_channel::Sender<Response>) -> Self {
|
||||||
|
Self {
|
||||||
|
to_boss,
|
||||||
|
from_boss,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn run(&mut self) {
|
||||||
|
while let Some(command) = self.from_boss.recv().await {
|
||||||
|
match command {
|
||||||
|
Command::Decrypt { content, pk } => {
|
||||||
|
// Process the decrypt command
|
||||||
|
// For now, just send a dummy response
|
||||||
|
let _ = self.to_boss.send(Response::DecryptedText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue