diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs b/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs index 1b7f945cee..5121f0b445 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs @@ -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::{PutSampleBuilder, TimestampBuilderTrait, ValueBuilderTrait}; +use zenoh::sample::builder::{SampleBuilder, TimestampBuilderTrait, ValueBuilderTrait}; use zenoh::time::Timestamp; use zenoh::Session; @@ -109,7 +109,7 @@ impl Aligner { let Value { payload, encoding, .. } = value; - let sample = PutSampleBuilder::new(key, payload) + let sample = SampleBuilder::put(key, payload) .encoding(encoding) .timestamp(ts) .into(); diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs index 62468ac6a1..feebfb588a 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs @@ -26,9 +26,7 @@ use zenoh::buffers::ZBuf; use zenoh::key_expr::KeyExpr; use zenoh::prelude::r#async::*; use zenoh::query::{ConsolidationMode, QueryTarget}; -use zenoh::sample::builder::{ - DeleteSampleBuilder, PutSampleBuilder, SampleBuilder, TimestampBuilderTrait, ValueBuilderTrait, -}; +use zenoh::sample::builder::{SampleBuilder, TimestampBuilderTrait, ValueBuilderTrait}; use zenoh::sample::{Sample, SampleKind}; use zenoh::time::{new_reception_timestamp, Timestamp, NTP64}; use zenoh::value::Value; @@ -309,7 +307,7 @@ impl StorageService { let Value { payload, encoding, .. } = data.value; - PutSampleBuilder::new(KeyExpr::from(k.clone()), payload) + SampleBuilder::put(KeyExpr::from(k.clone()), payload) .encoding(encoding) .timestamp(data.timestamp) .into() @@ -317,7 +315,7 @@ impl StorageService { Some(Update { kind: SampleKind::Delete, data, - }) => DeleteSampleBuilder::new(KeyExpr::from(k.clone())) + }) => SampleBuilder::delete(KeyExpr::from(k.clone())) .timestamp(data.timestamp) .into(), None => SampleBuilder::from(sample.clone()) diff --git a/zenoh/src/queryable.rs b/zenoh/src/queryable.rs index 2e3a1f585a..c9492394c4 100644 --- a/zenoh/src/queryable.rs +++ b/zenoh/src/queryable.rs @@ -137,8 +137,8 @@ impl Query { IntoKeyExpr: Into>, IntoPayload: Into, { - let sample_builder = PutSampleBuilder::new(key_expr, payload) - .with_qos(response::ext::QoSType::RESPONSE.into()); + let sample_builder = + SampleBuilder::put(key_expr, payload).with_qos(response::ext::QoSType::RESPONSE.into()); ReplyBuilder { query: self, sample_builder, diff --git a/zenoh/src/sample/builder.rs b/zenoh/src/sample/builder.rs index f74afdf2b3..8c507c8119 100644 --- a/zenoh/src/sample/builder.rs +++ b/zenoh/src/sample/builder.rs @@ -62,22 +62,21 @@ pub trait ValueBuilderTrait { pub struct SampleBuilder(Sample); impl SampleBuilder { - pub fn new(key_expr: IntoKeyExpr) -> Self + pub fn put( + key_expr: IntoKeyExpr, + payload: IntoPayload, + ) -> PutSampleBuilder where IntoKeyExpr: Into>, + IntoPayload: Into, { - Self(Sample { - key_expr: key_expr.into(), - payload: Payload::empty(), - kind: SampleKind::default(), - encoding: Encoding::default(), - timestamp: None, - qos: QoS::default(), - #[cfg(feature = "unstable")] - source_info: SourceInfo::empty(), - #[cfg(feature = "unstable")] - attachment: None, - }) + PutSampleBuilder::new(key_expr, payload) + } + pub fn delete(key_expr: IntoKeyExpr) -> DeleteSampleBuilder + where + IntoKeyExpr: Into>, + { + DeleteSampleBuilder::new(key_expr) } /// Allows to change keyexpr of [`Sample`] pub fn keyexpr(self, key_expr: IntoKeyExpr) -> Self @@ -149,7 +148,7 @@ impl From for PutSampleBuilder { } impl PutSampleBuilder { - pub fn new(key_expr: IntoKeyExpr, payload: IntoPayload) -> Self + fn new(key_expr: IntoKeyExpr, payload: IntoPayload) -> Self where IntoKeyExpr: Into>, IntoPayload: Into,