Skip to content

Commit

Permalink
removed extra uses
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Apr 1, 2024
1 parent bbe07f7 commit 4d0f6e5
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 144 deletions.
1 change: 0 additions & 1 deletion examples/examples/z_ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use std::time::{Duration, Instant};
use zenoh::config::Config;
use zenoh::prelude::sync::*;
use zenoh::publication::CongestionControl;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh_examples::CommonArgs;

fn main() {
Expand Down
1 change: 0 additions & 1 deletion examples/examples/z_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use clap::Parser;
use zenoh::config::Config;
use zenoh::prelude::sync::*;
use zenoh::publication::CongestionControl;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh_examples::CommonArgs;

fn main() {
Expand Down
1 change: 0 additions & 1 deletion examples/examples/z_pub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use clap::Parser;
use std::time::Duration;
use zenoh::config::Config;
use zenoh::prelude::r#async::*;
use zenoh::sample::builder::SampleBuilderTrait;
use zenoh_examples::CommonArgs;

#[tokio::main]
Expand Down
1 change: 0 additions & 1 deletion examples/examples/z_pub_shm_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use clap::Parser;
use zenoh::config::Config;
use zenoh::prelude::r#async::*;
use zenoh::publication::CongestionControl;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh::shm::SharedMemoryManager;
use zenoh_examples::CommonArgs;

Expand Down
1 change: 0 additions & 1 deletion examples/examples/z_pub_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use clap::Parser;
use std::convert::TryInto;
use zenoh::prelude::sync::*;
use zenoh::publication::CongestionControl;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh_examples::CommonArgs;

fn main() {
Expand Down
1 change: 0 additions & 1 deletion plugins/zenoh-plugin-rest/examples/z_serve_sse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use clap::{arg, Command};
use std::time::Duration;
use zenoh::prelude::r#async::*;
use zenoh::publication::CongestionControl;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh::{config::Config, key_expr::keyexpr};

const HTML: &str = r#"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ use std::str;
use std::str::FromStr;
use zenoh::payload::StringOrBase64;
use zenoh::prelude::r#async::*;
use zenoh::sample::builder::TimestampBuilderTrait;
use zenoh::sample::builder::ValueBuilderTrait;
use zenoh::time::Timestamp;
use zenoh::Session;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::str;
use zenoh::key_expr::{KeyExpr, OwnedKeyExpr};
use zenoh::payload::StringOrBase64;
use zenoh::prelude::r#async::*;
use zenoh::sample::builder::{SampleBuilder, TimestampBuilderTrait, ValueBuilderTrait};
use zenoh::sample::builder::SampleBuilder;
use zenoh::time::Timestamp;
use zenoh::Session;

Expand Down
53 changes: 20 additions & 33 deletions plugins/zenoh-plugin-storage-manager/src/replica/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,13 @@ use std::str::{self, FromStr};
use std::time::{SystemTime, UNIX_EPOCH};
use zenoh::buffers::buffer::SplitBuffer;
use zenoh::buffers::ZBuf;
use zenoh::key_expr::KeyExpr;
use zenoh::prelude::r#async::*;
use zenoh::query::{ConsolidationMode, QueryTarget};
use zenoh::sample::builder::{SampleBuilder, TimestampBuilderTrait, ValueBuilderTrait};
use zenoh::sample::builder::SampleBuilder;
use zenoh::sample::{Sample, SampleKind};
use zenoh::time::{new_reception_timestamp, Timestamp, NTP64};
use zenoh::value::Value;
use zenoh::{Result as ZResult, Session, SessionDeclarations};
use zenoh::{Result as ZResult, Session};
use zenoh_backend_traits::config::{GarbageCollectionConfig, StorageConfig};
use zenoh_backend_traits::{Capability, History, Persistence, StorageInsertionResult, StoredData};
use zenoh_keyexpr::key_expr::OwnedKeyExpr;
Expand Down Expand Up @@ -296,31 +295,25 @@ impl StorageService {
);
// there might be the case that the actual update was outdated due to a wild card update, but not stored yet in the storage.
// get the relevant wild card entry and use that value and timestamp to update the storage
let sample_to_store: Sample = match self
let sample_to_store: Sample = if let Some(update) = self
.ovderriding_wild_update(&k, sample.timestamp().unwrap())
.await
{
Some(Update {
kind: SampleKind::Put,
data,
}) => {
let Value {
payload, encoding, ..
} = data.value;
SampleBuilder::put(KeyExpr::from(k.clone()), payload)
.encoding(encoding)
.timestamp(data.timestamp)
.into()
match update.kind {
SampleKind::Put => {
SampleBuilder::put(KeyExpr::from(k.clone()), update.data.value.payload)
.encoding(update.data.value.encoding)
.timestamp(update.data.timestamp)
.into()
}
SampleKind::Delete => SampleBuilder::delete(KeyExpr::from(k.clone()))
.timestamp(update.data.timestamp)
.into(),
}
Some(Update {
kind: SampleKind::Delete,
data,
}) => SampleBuilder::delete(KeyExpr::from(k.clone()))
.timestamp(data.timestamp)
.into(),
None => SampleBuilder::from(sample.clone())
} else {
SampleBuilder::from(sample.clone())
.keyexpr(k.clone())
.into(),
.into()
};

let stripped_key = match self.strip_prefix(sample_to_store.key_expr()) {
Expand Down Expand Up @@ -520,12 +513,9 @@ impl StorageService {
match storage.get(stripped_key, q.parameters()).await {
Ok(stored_data) => {
for entry in stored_data {
let Value {
payload, encoding, ..
} = entry.value;
if let Err(e) = q
.reply(key.clone(), payload)
.encoding(encoding)
.reply(key.clone(), entry.value.payload)
.encoding(entry.value.encoding)
.timestamp(entry.timestamp)
.res()
.await
Expand Down Expand Up @@ -555,12 +545,9 @@ impl StorageService {
match storage.get(stripped_key, q.parameters()).await {
Ok(stored_data) => {
for entry in stored_data {
let Value {
payload, encoding, ..
} = entry.value;
if let Err(e) = q
.reply(q.key_expr().clone(), payload)
.encoding(encoding)
.reply(q.key_expr().clone(), entry.value.payload)
.encoding(entry.value.encoding)
.timestamp(entry.timestamp)
.res()
.await
Expand Down
1 change: 0 additions & 1 deletion zenoh-ext/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use zenoh::payload::PayloadReader;
use zenoh::prelude::r#async::*;
use zenoh::publication::Publisher;
use zenoh::query::ConsolidationMode;
use zenoh::sample::builder::QoSBuilderTrait;
use zenoh::Error as ZError;
use zenoh::Result as ZResult;
use zenoh::Session;
Expand Down
2 changes: 1 addition & 1 deletion zenoh-ext/src/querying_subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::time::Duration;
use zenoh::handlers::{locked, DefaultHandler};
use zenoh::prelude::r#async::*;
use zenoh::query::{QueryConsolidation, QueryTarget, ReplyKeyExpr};
use zenoh::sample::builder::{SampleBuilder, TimestampBuilderTrait};
use zenoh::sample::builder::SampleBuilder;
use zenoh::subscriber::{Reliability, Subscriber};
use zenoh::time::{new_reception_timestamp, Timestamp};
use zenoh::Result as ZResult;
Expand Down
65 changes: 31 additions & 34 deletions zenoh/src/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
//! Publishing primitives.
use crate::net::primitives::Primitives;
use crate::prelude::*;
use crate::sample::builder::{
QoSBuilderTrait, SampleBuilderTrait, TimestampBuilderTrait, ValueBuilderTrait,
};
#[zenoh_macros::unstable]
use crate::sample::Attachment;
use crate::sample::{DataInfo, QoS, Sample, SampleFields, SampleKind};
Expand Down Expand Up @@ -105,29 +102,14 @@ impl<T> QoSBuilderTrait for PublicationBuilder<PublisherBuilder<'_, '_>, T> {
}
}

impl<P, T> TimestampBuilderTrait for PublicationBuilder<P, T> {
fn timestamp<TS: Into<Option<uhlc::Timestamp>>>(self, timestamp: TS) -> Self {
Self {
timestamp: timestamp.into(),
..self
}
}
}

impl<P, T> SampleBuilderTrait for PublicationBuilder<P, T> {
#[cfg(feature = "unstable")]
fn source_info(self, source_info: SourceInfo) -> Self {
Self {
source_info,
..self
}
}
#[cfg(feature = "unstable")]
fn attachment<TA: Into<Option<Attachment>>>(self, attachment: TA) -> Self {
Self {
attachment: attachment.into(),
..self
}
impl<T> PublicationBuilder<PublisherBuilder<'_, '_>, T> {
/// Restrict the matching subscribers that will receive the published data
/// to the ones that have the given [`Locality`](crate::prelude::Locality).
#[zenoh_macros::unstable]
#[inline]
pub fn allowed_destination(mut self, destination: Locality) -> Self {
self.publisher = self.publisher.allowed_destination(destination);
self
}
}

Expand Down Expand Up @@ -163,14 +145,29 @@ impl<P> ValueBuilderTrait for PublicationBuilder<P, PublicationBuilderPut> {
}
}

impl<T> PublicationBuilder<PublisherBuilder<'_, '_>, T> {
/// Restrict the matching subscribers that will receive the published data
/// to the ones that have the given [`Locality`](crate::prelude::Locality).
#[zenoh_macros::unstable]
#[inline]
pub fn allowed_destination(mut self, destination: Locality) -> Self {
self.publisher = self.publisher.allowed_destination(destination);
self
impl<P, T> SampleBuilderTrait for PublicationBuilder<P, T> {
#[cfg(feature = "unstable")]
fn source_info(self, source_info: SourceInfo) -> Self {
Self {
source_info,
..self
}
}
#[cfg(feature = "unstable")]
fn attachment<TA: Into<Option<Attachment>>>(self, attachment: TA) -> Self {
Self {
attachment: attachment.into(),
..self
}
}
}

impl<P, T> TimestampBuilderTrait for PublicationBuilder<P, T> {
fn timestamp<TS: Into<Option<uhlc::Timestamp>>>(self, timestamp: TS) -> Self {
Self {
timestamp: timestamp.into(),
..self
}
}
}

Expand Down
Loading

0 comments on commit 4d0f6e5

Please sign in to comment.