diff options
| author | LLLL Colonq <llll@colonq> | 2025-02-16 22:55:43 -0500 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2025-02-16 22:55:43 -0500 |
| commit | 4d0a8140130ebd0f46744b86eeb2a708657a942e (patch) | |
| tree | 6b1a11e07173c769d0f3522c2f6088409b69332d /src/common/overlay/fig.rs | |
| parent | 33d69b282e082acce3c5d36cc08cd99a7ccf738d (diff) | |
Switch to workspace
Diffstat (limited to 'src/common/overlay/fig.rs')
| -rw-r--r-- | src/common/overlay/fig.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/src/common/overlay/fig.rs b/src/common/overlay/fig.rs deleted file mode 100644 index b60f8e9..0000000 --- a/src/common/overlay/fig.rs +++ /dev/null @@ -1,40 +0,0 @@ -use std::io::{BufRead, Write}; - -#[derive(Debug, Clone)] -pub struct Message { - pub event: lexpr::Value, - pub data: lexpr::Value, -} - -pub struct Client { - reader: std::io::BufReader<std::net::TcpStream>, -} -impl Client { - pub fn new(addr: &str, subs: &[lexpr::Value]) -> Self { - let mut socket = std::net::TcpStream::connect(addr).expect("failed to connect to message bus"); - socket.set_nonblocking(true).expect("failed to set message bus socket nonblocking"); - for s in subs { - write!(socket, "(sub {})\n", s).expect("failed to send subscribe message to bus"); - } - let reader = std::io::BufReader::new(socket); - Self { reader, } - } - pub fn pump(&mut self) -> Option<Message> { - let mut buf = String::new(); - match self.reader.read_line(&mut buf) { - Ok(l) => match lexpr::from_str(&buf) { - Ok(v) => { - match v.as_cons() { - Some(cs) => { - Some(Message { event: cs.car().clone(), data: cs.cdr().clone() }) - }, - _ => { log::error!("malformed message bus input s-expression: {}", v); None }, - } - }, - Err(e) => { log::error!("malformed message bus input line: {}", e); None }, - }, - Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => None, - Err(e) => panic!("IO error on message bus: {}", e), - } - } -} |
