diff --git a/src/broker/broker.rs b/src/broker/brokerimpl.rs similarity index 99% rename from src/broker/broker.rs rename to src/broker/brokerimpl.rs index 4fe604a..2ac156e 100644 --- a/src/broker/broker.rs +++ b/src/broker/brokerimpl.rs @@ -14,7 +14,7 @@ use log::Level; use crate::broker::node::{DIR_APP_BROKER_CURRENTCLIENT, DIR_APP_BROKER, AppBrokerCurrentClientNode, AppBrokerNode, METH_SUBSCRIBE}; use crate::metamethod::{MetaMethod, AccessLevel}; -pub struct Broker { +pub struct BrokerImpl { peers: HashMap, mounts: BTreeMap, access: AccessControl, @@ -29,7 +29,7 @@ pub struct Broker { } -impl Broker { +impl BrokerImpl { pub(crate) fn new(access: AccessControl) -> Self { let (command_sender, command_receiver) = unbounded(); let mut role_access: HashMap> = Default::default(); @@ -492,7 +492,7 @@ impl Broker { ) } fn client_info(&mut self, client_id: CliId) -> Option { - self.peers.get(&client_id).map(|peer| Broker::peer_to_info(client_id, peer)) + self.peers.get(&client_id).map(|peer| BrokerImpl::peer_to_info(client_id, peer)) } async fn disconnect_client(&mut self, client_id: CliId) -> crate::Result<()> { let peer = self.peers.get(&client_id).ok_or("Invalid client ID")?; @@ -503,7 +503,7 @@ impl Broker { for (client_id, peer) in &self.peers { if let Some(mount_point1) = &peer.mount_point { if mount_point1 == mount_point { - return Some(Broker::peer_to_info(*client_id, peer)); + return Some(BrokerImpl::peer_to_info(*client_id, peer)); } } } diff --git a/src/broker/mod.rs b/src/broker/mod.rs index 66a5706..033a46d 100644 --- a/src/broker/mod.rs +++ b/src/broker/mod.rs @@ -13,14 +13,14 @@ use crate::shvnode::{ShvNode}; use async_std::stream::StreamExt; use futures::select; use futures::FutureExt; -use crate::broker::broker::Broker; +use crate::broker::brokerimpl::BrokerImpl; pub mod config; pub mod peer; pub mod node; #[cfg(test)] mod test; -mod broker; +mod brokerimpl; #[derive(Debug)] pub(crate) enum BrokerCommand { @@ -194,7 +194,7 @@ struct PendingRpcCall { response_sender: Sender, } -pub(crate) async fn broker_loop(mut broker: Broker) { +pub(crate) async fn broker_loop(mut broker: BrokerImpl) { loop { select! { command = broker.command_receiver.recv().fuse() => match command { @@ -213,7 +213,7 @@ pub(crate) async fn broker_loop(mut broker: Broker) { pub async fn accept_loop(config: BrokerConfig, access: AccessControl) -> crate::Result<()> { if let Some(address) = config.listen.tcp.clone() { - let broker = Broker::new(access); + let broker = BrokerImpl::new(access); let broker_sender = broker.command_sender.clone(); let parent_broker_peer_config = config.parent_broker.clone(); let broker_task = task::spawn(crate::broker::broker_loop(broker)); diff --git a/src/broker/test.rs b/src/broker/test.rs index 09a7768..f1a89a4 100644 --- a/src/broker/test.rs +++ b/src/broker/test.rs @@ -3,7 +3,7 @@ use async_std::channel::{Receiver}; use crate::broker::{BrokerToPeerMessage, PeerKind, BrokerCommand, Sender, SubscribePath}; use crate::rpcmessage::CliId; use crate::{List, RpcMessage, RpcMessageMetaTags, RpcValue}; -use crate::broker::broker::Broker; +use crate::broker::brokerimpl::BrokerImpl; use crate::broker::config::BrokerConfig; use crate::broker::node::{METH_SUBSCRIBE, METH_UNSUBSCRIBE}; use crate::rpcframe::RpcFrame; @@ -51,7 +51,7 @@ async fn call(path: &str, method: &str, param: Option, ctx: &CallCtx<' fn test_broker() { let config = BrokerConfig::default(); let access = config.access.clone(); - let broker = Broker::new(access); + let broker = BrokerImpl::new(access); let roles = broker.flatten_roles("child-broker").unwrap(); assert_eq!(roles, vec!["child-broker", "device", "client", "ping", "subscribe", "browse"]); } @@ -60,7 +60,7 @@ fn test_broker() { async fn test_broker_loop() { let config = BrokerConfig::default(); let access = config.access.clone(); - let broker = Broker::new(access); + let broker = BrokerImpl::new(access); let broker_sender = broker.command_sender.clone(); let broker_task = task::spawn(crate::broker::broker_loop(broker)); diff --git a/src/serialrw.rs b/src/serialrw.rs index de817ba..17cfa05 100644 --- a/src/serialrw.rs +++ b/src/serialrw.rs @@ -21,7 +21,7 @@ enum Byte { Stx, Etx, Atx, - FramingError, + FramingError(u8), } pub struct SerialFrameReader { reader: R, @@ -60,7 +60,7 @@ impl SerialFrameReader { EESC => Ok(crate::serialrw::Byte::Data(ESC)), b => { warn!("Framing error, invalid escape byte {}", b); - Ok(crate::serialrw::Byte::FramingError) + Ok(crate::serialrw::Byte::FramingError(b)) } } } @@ -78,7 +78,7 @@ impl SerialFrameReader { Byte::Stx => { data.push( STX) } Byte::Etx => { data.push( ETX ) } Byte::Atx => { data.push( ATX ) } - Byte::FramingError(e) => { return Err(format!("Framing error, invalid character {e}").into()) } + Byte::FramingError(b) => { return Err(format!("Framing error, invalid character {b}").into()) } } } Err(_) => { break }