diff --git a/src/main.rs b/src/main.rs index 3eac7cc..4ab5bb7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,7 +26,7 @@ impl syslog_rpc::Server for Serv { let binary_msg = Message { from: message.from.clone(), text: None, - binary: message.binary.clone() + binary: message.binary.clone(), }; for subscriber in &*self.binary_subscribers.read() { if (binary_msg.from != subscriber.1) || (!subscriber.2.contains(&binary.kind)) { @@ -43,7 +43,9 @@ impl syslog_rpc::Server for Serv { } fn subscribe_to_binary(&self, from: u64, message_from: String, kinds: Vec) { - self.binary_subscribers.write().push((from, message_from, kinds)); + self.binary_subscribers + .write() + .push((from, message_from, kinds)); } } diff --git a/syslog_msg_ipc/src/lib.rs b/syslog_msg_ipc/src/lib.rs index f490ea3..df636db 100644 --- a/syslog_msg_ipc/src/lib.rs +++ b/syslog_msg_ipc/src/lib.rs @@ -1,7 +1,7 @@ use std::{collections::VecDeque, os::mikros::ipc}; use parking_lot::Mutex; -pub use syslog_structs::{Message, BinaryMessage}; +pub use syslog_structs::{BinaryMessage, Message}; const PROTO: u16 = 1; static MSG_BUF: Mutex> = Mutex::new(VecDeque::new()); diff --git a/syslog_rpc/src/lib.rs b/syslog_rpc/src/lib.rs index c02a79d..8422ce6 100644 --- a/syslog_rpc/src/lib.rs +++ b/syslog_rpc/src/lib.rs @@ -3,7 +3,7 @@ use std::os::mikros::ipc::rpc::{self, IncomingCall}; use parking_lot::RwLock; -pub use syslog_structs::{Message, BinaryMessage}; +pub use syslog_structs::{BinaryMessage, Message}; static SERVER: RwLock>> = RwLock::new(None); @@ -23,15 +23,30 @@ impl Client { Self(pid) } - pub fn send_text_message(&self, from: impl Into, text: impl Into) -> Result<(), ()> { + pub fn send_text_message( + &self, + from: impl Into, + text: impl Into, + ) -> Result<(), ()> { self.send_raw_message(Message::new_text(from, text)) } - pub fn send_binary_message(&self, from: impl Into, kind: u64, data: impl Into>) -> Result<(), ()> { + pub fn send_binary_message( + &self, + from: impl Into, + kind: u64, + data: impl Into>, + ) -> Result<(), ()> { self.send_raw_message(Message::new_binary(from, kind, data)) } - pub fn send_text_binary_message(&self, from: impl Into, text: impl Into, kind: u64, data: impl Into>) -> Result<(), ()> { + pub fn send_text_binary_message( + &self, + from: impl Into, + text: impl Into, + kind: u64, + data: impl Into>, + ) -> Result<(), ()> { self.send_raw_message(Message::new_text_binary(from, text, kind, data)) } @@ -43,15 +58,18 @@ impl Client { } pub fn subscribe_to_text(&self) { - postcard::from_bytes( - &rpc::send_call(self.0, PROTO, 1, &[]).get_return(), - ) - .unwrap() + postcard::from_bytes(&rpc::send_call(self.0, PROTO, 1, &[]).get_return()).unwrap() } pub fn subscribe_to_binary(&self, message_from: String, kinds: Vec) { postcard::from_bytes( - &rpc::send_call(self.0, PROTO, 2, &postcard::to_stdvec(&(message_from, kinds)).unwrap()).get_return(), + &rpc::send_call( + self.0, + PROTO, + 2, + &postcard::to_stdvec(&(message_from, kinds)).unwrap(), + ) + .get_return(), ) .unwrap() } @@ -79,7 +97,8 @@ fn callback(call: IncomingCall) { call.send_return(&ret); } else if call.func == 2 { let (message_from, kinds) = postcard::from_bytes(&call.args).unwrap(); - let ret = postcard::to_stdvec(&server.subscribe_to_binary(call.from, message_from, kinds)).unwrap(); + let ret = postcard::to_stdvec(&server.subscribe_to_binary(call.from, message_from, kinds)) + .unwrap(); call.send_return(&ret); } } diff --git a/syslog_structs/src/lib.rs b/syslog_structs/src/lib.rs index 8bb1c8f..a513c91 100644 --- a/syslog_structs/src/lib.rs +++ b/syslog_structs/src/lib.rs @@ -27,7 +27,12 @@ impl Message { } } - pub fn new_text_binary(from: impl Into, text: impl Into, kind: u64, data: impl Into>) -> Self { + pub fn new_text_binary( + from: impl Into, + text: impl Into, + kind: u64, + data: impl Into>, + ) -> Self { Self { from: from.into(), text: Some(text.into()), @@ -42,5 +47,5 @@ impl Message { #[derive(Serialize, Deserialize, Clone, Debug)] pub struct BinaryMessage { pub kind: u64, - pub data: Vec + pub data: Vec, }