Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Jun 11, 2024
1 parent 0d7b313 commit 4a6d8be
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 23 deletions.
10 changes: 5 additions & 5 deletions commons/zenoh-protocol/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ use alloc::{
format,
string::{String, ToString},
};
use serde::{Deserialize, Serialize};
use core::{
convert::{From, TryFrom, TryInto},
fmt,
hash::Hash,
str::FromStr,
};

use serde::{Deserialize, Serialize};
pub use uhlc::{Timestamp, NTP64};
use zenoh_keyexpr::OwnedKeyExpr;
use zenoh_result::{bail, zerror};
Expand Down Expand Up @@ -131,8 +131,6 @@ impl FromStr for ZenohId {
}
}



// Mimics uhlc::SizeError,
#[derive(Debug, Clone, Copy)]
pub struct SizeError(usize);
Expand Down Expand Up @@ -285,7 +283,10 @@ impl<'de> serde::Deserialize<'de> for ZenohIdInner {
type Value = ZenohIdInner;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str(&format!("An hex string of 1-{} bytes", ZenohIdInner::MAX_SIZE))
formatter.write_str(&format!(
"An hex string of 1-{} bytes",
ZenohIdInner::MAX_SIZE
))
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
Expand Down Expand Up @@ -355,7 +356,6 @@ impl From<EntityGlobalIdInner> for EntityGlobalId {
}
}


#[repr(u8)]
#[derive(Debug, Default, Copy, Clone, Eq, Hash, PartialEq)]
pub enum Priority {
Expand Down
2 changes: 1 addition & 1 deletion commons/zenoh-protocol/src/scouting/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
use alloc::vec::Vec;
use std::fmt;

use crate::core::{Locator, WhatAmI, ZenohIdInner};

/// # Hello message
Expand Down Expand Up @@ -165,4 +166,3 @@ impl fmt::Display for Hello {
.finish()
}
}

6 changes: 5 additions & 1 deletion io/zenoh-transport/src/unicast/establishment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ pub trait AcceptFsm {
/*************************************/
/* FUNCTIONS */
/*************************************/
pub(super) fn compute_sn(zid1: ZenohIdInner, zid2: ZenohIdInner, resolution: Resolution) -> TransportSn {
pub(super) fn compute_sn(
zid1: ZenohIdInner,
zid2: ZenohIdInner,
resolution: Resolution,
) -> TransportSn {
// Create a random yet deterministic initial_sn.
// In case of multilink it's important that the same initial_sn is used for every connection attempt.
// Instead of storing the state everywhere, we make sure that the we always compute the same initial_sn.
Expand Down
3 changes: 2 additions & 1 deletion io/zenoh-transport/tests/multicast_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ mod tests {
use zenoh_link::Link;
use zenoh_protocol::{
core::{
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, ZenohIdInner,
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI,
ZenohIdInner,
},
network::{
push::{
Expand Down
3 changes: 2 additions & 1 deletion io/zenoh-transport/tests/multicast_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ mod tests {
use zenoh_link::Link;
use zenoh_protocol::{
core::{
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, ZenohIdInner,
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI,
ZenohIdInner,
},
network::{
push::{
Expand Down
3 changes: 2 additions & 1 deletion io/zenoh-transport/tests/unicast_compression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ mod tests {
use zenoh_link::Link;
use zenoh_protocol::{
core::{
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, ZenohIdInner,
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI,
ZenohIdInner,
},
network::{
push::ext::{NodeIdType, QoSType},
Expand Down
3 changes: 2 additions & 1 deletion io/zenoh-transport/tests/unicast_defragmentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use std::{convert::TryFrom, sync::Arc, time::Duration};
use zenoh_core::ztimeout;
use zenoh_protocol::{
core::{
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, ZenohIdInner,
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI,
ZenohIdInner,
},
network::{
push::{
Expand Down
3 changes: 2 additions & 1 deletion io/zenoh-transport/tests/unicast_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ use zenoh_core::ztimeout;
use zenoh_link::Link;
use zenoh_protocol::{
core::{
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI, ZenohIdInner,
Channel, CongestionControl, Encoding, EndPoint, Priority, Reliability, WhatAmI,
ZenohIdInner,
},
network::{
push::ext::{NodeIdType, QoSType},
Expand Down
4 changes: 3 additions & 1 deletion zenoh/src/api/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ use zenoh_core::{zconfigurable, zread, Resolvable, Resolve, ResolveClosure, Reso
use zenoh_protocol::network::{declare::SubscriberId, ext};
use zenoh_protocol::{
core::{
key_expr::{keyexpr, OwnedKeyExpr}, AtomicExprId, CongestionControl, EntityId, ExprId, Reliability, WireExpr, ZenohId, EMPTY_EXPR_ID
key_expr::{keyexpr, OwnedKeyExpr},
AtomicExprId, CongestionControl, EntityId, ExprId, Reliability, WireExpr, ZenohId,
EMPTY_EXPR_ID,
},
network::{
self,
Expand Down
6 changes: 3 additions & 3 deletions zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ pub mod session {

/// Tools to access information about the current zenoh [`Session`](crate::Session).
pub mod info {
pub use zenoh_protocol::core::ZenohId;
pub use zenoh_protocol::core::EntityGlobalId;
pub use zenoh_protocol::core::EntityId;
pub use zenoh_protocol::core::{EntityGlobalId, EntityId, ZenohId};

pub use crate::api::info::{
PeersZenohIdBuilder, RoutersZenohIdBuilder, SessionInfo, ZenohIdBuilder,
};
Expand Down Expand Up @@ -328,6 +327,7 @@ pub mod handlers {
/// Scouting primitives
pub mod scouting {
pub use zenoh_protocol::scouting::hello::Hello;

pub use crate::api::scouting::{scout, Scout, ScoutBuilder};
}

Expand Down
6 changes: 5 additions & 1 deletion zenoh/src/net/routing/hat/linkstate_peer/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@ impl Network {
self.graph.update_edge(idx1, idx2, weight);
}

pub(super) fn link_states(&mut self, link_states: Vec<LinkState>, src: ZenohIdInner) -> Changes {
pub(super) fn link_states(
&mut self,
link_states: Vec<LinkState>,
src: ZenohIdInner,
) -> Changes {
tracing::trace!("{} Received from {} raw: {:?}", self.name, src, link_states);
let strong_runtime = self.runtime.upgrade().unwrap();

Expand Down
6 changes: 5 additions & 1 deletion zenoh/src/net/routing/hat/router/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,11 @@ impl Network {
self.graph.update_edge(idx1, idx2, weight);
}

pub(super) fn link_states(&mut self, link_states: Vec<LinkState>, src: ZenohIdInner) -> Changes {
pub(super) fn link_states(
&mut self,
link_states: Vec<LinkState>,
src: ZenohIdInner,
) -> Changes {
tracing::trace!("{} Received from {} raw: {:?}", self.name, src, link_states);

let graph = &self.graph;
Expand Down
12 changes: 10 additions & 2 deletions zenoh/src/net/routing/hat/router/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,11 @@ fn propagate_forget_sourced_subscription(
}
}

fn unregister_router_subscription(tables: &mut Tables, res: &mut Arc<Resource>, router: &ZenohIdInner) {
fn unregister_router_subscription(
tables: &mut Tables,
res: &mut Arc<Resource>,
router: &ZenohIdInner,
) {
res_hat_mut!(res).router_subs.retain(|sub| sub != router);

if res_hat!(res).router_subs.is_empty() {
Expand Down Expand Up @@ -771,7 +775,11 @@ pub(super) fn pubsub_tree_change(
update_data_routes_from(tables, &mut tables.root_res.clone());
}

pub(super) fn pubsub_linkstate_change(tables: &mut Tables, zid: &ZenohIdInner, links: &[ZenohIdInner]) {
pub(super) fn pubsub_linkstate_change(
tables: &mut Tables,
zid: &ZenohIdInner,
links: &[ZenohIdInner],
) {
if let Some(src_face) = tables.get_face(zid).cloned() {
if hat!(tables).router_peers_failover_brokering && src_face.whatami == WhatAmI::Peer {
for res in face_hat!(src_face).remote_subs.values() {
Expand Down
12 changes: 10 additions & 2 deletions zenoh/src/net/routing/hat/router/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,11 @@ fn propagate_forget_sourced_queryable(
}
}

fn unregister_router_queryable(tables: &mut Tables, res: &mut Arc<Resource>, router: &ZenohIdInner) {
fn unregister_router_queryable(
tables: &mut Tables,
res: &mut Arc<Resource>,
router: &ZenohIdInner,
) {
res_hat_mut!(res).router_qabls.remove(router);

if res_hat!(res).router_qabls.is_empty() {
Expand Down Expand Up @@ -857,7 +861,11 @@ pub(super) fn queries_remove_node(tables: &mut Tables, node: &ZenohIdInner, net_
}
}

pub(super) fn queries_linkstate_change(tables: &mut Tables, zid: &ZenohIdInner, links: &[ZenohIdInner]) {
pub(super) fn queries_linkstate_change(
tables: &mut Tables,
zid: &ZenohIdInner,
links: &[ZenohIdInner],
) {
if let Some(src_face) = tables.get_face(zid) {
if hat!(tables).router_peers_failover_brokering && src_face.whatami == WhatAmI::Peer {
for res in face_hat!(src_face).remote_qabls.values() {
Expand Down
3 changes: 2 additions & 1 deletion zenoh/src/net/tests/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ use zenoh_config::Config;
use zenoh_core::zlock;
use zenoh_protocol::{
core::{
key_expr::keyexpr, Encoding, ExprId, Reliability, WhatAmI, WireExpr, ZenohIdInner, EMPTY_EXPR_ID,
key_expr::keyexpr, Encoding, ExprId, Reliability, WhatAmI, WireExpr, ZenohIdInner,
EMPTY_EXPR_ID,
},
network::{
declare::subscriber::ext::SubscriberInfo, ext, Declare, DeclareBody, DeclareKeyExpr,
Expand Down

0 comments on commit 4a6d8be

Please sign in to comment.