Skip to content

Commit

Permalink
Improve locality default and optionality (#321)
Browse files Browse the repository at this point in the history
* Convert Option<Locality> to Locality::default() for publisher

* Convert Option<Locality> to Locality::default() for queryable

* Convert Option<Locality> to Locality::default() for subscriber

* Convert Option<Locality> to Locality::default() for query

* Remove extra session lock

* Use Locality::default() in open() and init() (#371)

Co-authored-by: OlivierHecart <[email protected]>
  • Loading branch information
Mallets and OlivierHecart authored Sep 15, 2022
1 parent 8613783 commit fd47be0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
16 changes: 8 additions & 8 deletions zenoh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ where
{
OpenBuilder {
config,
publications_destination: Locality::Any,
subscribers_origin: Locality::Any,
queries_destination: Locality::Any,
queryables_origin: Locality::Any,
publications_destination: Locality::default(),
subscribers_origin: Locality::default(),
queries_destination: Locality::default(),
queryables_origin: Locality::default(),
}
}

Expand Down Expand Up @@ -356,10 +356,10 @@ where
pub fn init(runtime: Runtime) -> InitBuilder {
InitBuilder {
runtime,
publications_destination: Locality::Any,
subscribers_origin: Locality::Any,
queries_destination: Locality::Any,
queryables_origin: Locality::Any,
publications_destination: Locality::default(),
subscribers_origin: Locality::default(),
queries_destination: Locality::default(),
queryables_origin: Locality::default(),
aggregated_subscribers: vec![],
aggregated_publishers: vec![],
}
Expand Down
6 changes: 6 additions & 0 deletions zenoh/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ pub enum Locality {
Any,
}

impl Default for Locality {
fn default() -> Self {
Locality::Any
}
}

/// A zenoh sample.
#[non_exhaustive]
#[derive(Clone, Debug)]
Expand Down

0 comments on commit fd47be0

Please sign in to comment.