Skip to content

Commit

Permalink
Rename broker::Broker to broker::BrokerImpl, to fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
Fanda Vacek committed Apr 15, 2024
1 parent 705b3e0 commit aa8d093
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/broker/broker.rs → src/broker/brokerimpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<CliId, Peer>,
mounts: BTreeMap<String, Mount>,
access: AccessControl,
Expand All @@ -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<String, Vec<ParsedAccessRule>> = Default::default();
Expand Down Expand Up @@ -492,7 +492,7 @@ impl Broker {
)
}
fn client_info(&mut self, client_id: CliId) -> Option<rpcvalue::Map> {
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")?;
Expand All @@ -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));
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/broker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -194,7 +194,7 @@ struct PendingRpcCall {
response_sender: Sender<RpcFrame>,
}

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 {
Expand All @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions src/broker/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -51,7 +51,7 @@ async fn call(path: &str, method: &str, param: Option<RpcValue>, 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"]);
}
Expand All @@ -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));

Expand Down
6 changes: 3 additions & 3 deletions src/serialrw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum Byte {
Stx,
Etx,
Atx,
FramingError,
FramingError(u8),
}
pub struct SerialFrameReader<R: AsyncRead + Unpin + Send> {
reader: R,
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<R: AsyncRead + Unpin + Send> SerialFrameReader<R> {
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))
}
}
}
Expand All @@ -78,7 +78,7 @@ impl<R: AsyncRead + Unpin + Send> SerialFrameReader<R> {
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 }
Expand Down

0 comments on commit aa8d093

Please sign in to comment.