Skip to content

Commit

Permalink
Merge pull request #560 from eclipse-zenoh/minor-fixes
Browse files Browse the repository at this point in the history
fix package-scale compilation for subcrates, make ketrees generic over their hasher
  • Loading branch information
p-avital authored Oct 4, 2023
2 parents c6fec02 + 60b00f3 commit fd9e407
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions commons/zenoh-keyexpr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ hashbrown = { workspace = true }
[dev-dependencies]
criterion = { workspace = true }
lazy_static = { workspace = true }
rand = { workspace = true, features = ["default"] }

[[bench]]
name = "keyexpr_tree"
Expand Down
15 changes: 11 additions & 4 deletions commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,29 @@
// ZettaScale Zenoh Team, <[email protected]>
//

use core::hash::Hasher;
#[cfg(not(feature = "std"))]
// `SipHasher` is deprecated in favour of a symbol that only exists in `std`
#[allow(deprecated)]
use core::hash::SipHasher as DefaultHasher;
#[cfg(not(feature = "std"))]
use hashbrown::{
hash_map::{Entry, Iter, IterMut, Values, ValuesMut},
HashMap,
};
#[cfg(feature = "std")]
use std::collections::{
hash_map::{Entry, Iter, IterMut, Values, ValuesMut},
hash_map::{DefaultHasher, Entry, Iter, IterMut, Values, ValuesMut},
HashMap,
};

use crate::keyexpr_tree::*;

pub struct HashMapProvider;
impl<T: 'static> IChildrenProvider<T> for HashMapProvider {
type Assoc = HashMap<OwnedKeyExpr, T>;
pub struct HashMapProvider<Hash: Hasher + Default + 'static = DefaultHasher>(

Check warning on line 33 in commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs

View workflow job for this annotation

GitHub Actions / Run no_std checks

use of deprecated struct `core::hash::SipHasher`: use `std::collections::hash_map::DefaultHasher` instead

Check warning on line 33 in commons/zenoh-keyexpr/src/keyexpr_tree/impls/hashmap_impl.rs

View workflow job for this annotation

GitHub Actions / Run no_std checks

use of deprecated struct `core::hash::SipHasher`: use `std::collections::hash_map::DefaultHasher` instead
core::marker::PhantomData<Hash>,
);
impl<T: 'static, Hash: Hasher + Default + 'static> IChildrenProvider<T> for HashMapProvider<Hash> {
type Assoc = HashMap<OwnedKeyExpr, T, core::hash::BuildHasherDefault<Hash>>;
}

#[cfg(not(feature = "std"))]
Expand Down
14 changes: 12 additions & 2 deletions commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@
// ZettaScale Zenoh Team, <[email protected]>
//

use core::hash::Hasher;
#[cfg(not(feature = "std"))]
// `SipHasher` is deprecated in favour of a symbol that only exists in `std`
#[allow(deprecated)]
use core::hash::SipHasher as DefaultHasher;
#[cfg(feature = "std")]
use std::collections::hash_map::DefaultHasher;

use crate::keyexpr_tree::*;
use keyed_set::{KeyExtractor, KeyedSet};

pub struct KeyedSetProvider;
impl<T: 'static> IChildrenProvider<T> for KeyedSetProvider {
pub struct KeyedSetProvider<Hash: Hasher + Default + 'static = DefaultHasher>(

Check warning on line 26 in commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs

View workflow job for this annotation

GitHub Actions / Run no_std checks

use of deprecated struct `core::hash::SipHasher`: use `std::collections::hash_map::DefaultHasher` instead

Check warning on line 26 in commons/zenoh-keyexpr/src/keyexpr_tree/impls/keyed_set_impl.rs

View workflow job for this annotation

GitHub Actions / Run no_std checks

use of deprecated struct `core::hash::SipHasher`: use `std::collections::hash_map::DefaultHasher` instead
core::marker::PhantomData<Hash>,
);
impl<T: 'static, Hash: Hasher + Default + 'static> IChildrenProvider<T> for KeyedSetProvider<Hash> {
type Assoc = KeyedSet<T, ChunkExtractor>;
}
#[derive(Debug, Default, Clone, Copy)]
Expand Down
3 changes: 2 additions & 1 deletion commons/zenoh-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ rand = { workspace = true, features = ["alloc", "getrandom"], optional = true }
serde = { workspace = true, features = ["alloc"] }
uhlc = { workspace = true, default-features = false }
uuid = { workspace = true } # Needs a getrandom::getrandom() custom implementation on embedded (in root crate)
zenoh-buffers = { workspace = true, default-features = false }
zenoh-buffers = { workspace = true, default-features = false }
zenoh-keyexpr = { workspace = true }
zenoh-result = { workspace = true }

# NOTE: May cause problems when testing no_std stuff. Check this tool: https://docs.rs/crate/cargo-no-dev-deps/0.1.0
[dev-dependencies]
lazy_static = { workspace = true }
rand = { workspace = true, features = ["default"] }
2 changes: 1 addition & 1 deletion commons/zenoh-protocol/src/network/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub mod ext {
impl TargetType {
#[cfg(feature = "test")]
pub fn rand() -> Self {
use rand::prelude::SliceRandom;
use rand::prelude::*;
let mut rng = rand::thread_rng();

*[
Expand Down
4 changes: 4 additions & 0 deletions io/zenoh-transport/src/unicast/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ pub struct TransportManagerBuilderUnicast {
pub(super) max_links: usize,
#[cfg(feature = "shared-memory")]
pub(super) is_shm: bool,
#[cfg(feature = "transport_compression")]
pub(super) is_compressed: bool,
#[cfg(feature = "transport_auth")]
pub(super) authenticator: Auth,
pub(super) is_lowlatency: bool,
Expand Down Expand Up @@ -251,6 +253,8 @@ impl Default for TransportManagerBuilderUnicast {
max_links: *transport.max_links(),
#[cfg(feature = "shared-memory")]
is_shm: *shm.enabled(),
#[cfg(feature = "transport_compression")]
is_compressed: false,
#[cfg(feature = "transport_auth")]
authenticator: Auth::default(),
is_lowlatency: *transport.lowlatency(),
Expand Down
2 changes: 1 addition & 1 deletion io/zenoh-transport/src/unicast/universal/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl TransportLinkUnicast {
};

#[cfg(all(feature = "unstable", feature = "transport_compression"))]
let is_compressed = self.transport.config.manager.config.unicast.is_compressed;
let is_compressed = self.transport.manager.config.unicast.is_compressed;

// The pipeline
let (producer, consumer) = TransmissionPipeline::make(config, priority_tx);
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,7 @@ pub fn route_query(
ext_qos: ext::QoSType::request_default(), // TODO
ext_tstamp: None,
ext_nodeid: ext::NodeIdType {
node_id: context.map(|c| c.tree_id).unwrap_or(0) as u16,
node_id: context.unwrap_or(0),
},
ext_target: *t,
ext_budget: None,
Expand Down

0 comments on commit fd9e407

Please sign in to comment.