diff --git a/plugins/zenoh-plugin-rest/src/lib.rs b/plugins/zenoh-plugin-rest/src/lib.rs index 74da23679f..c90bbe5ac1 100644 --- a/plugins/zenoh-plugin-rest/src/lib.rs +++ b/plugins/zenoh-plugin-rest/src/lib.rs @@ -420,7 +420,7 @@ async fn query(mut req: Request<(Arc, String)>) -> tide::Result { @@ -464,13 +464,7 @@ async fn write(mut req: Request<(Arc, String)>) -> tide::Result { - session - .put(&key_expr, bytes) - .with_encoding(encoding) - .res() - .await - } + SampleKind::Put => session.put(&key_expr, bytes).encoding(encoding).res().await, SampleKind::Delete => session.delete(&key_expr).res().await, }; match res { diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs b/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs index 973fb89abe..b2d2bdc399 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/align_queryable.rs @@ -129,7 +129,7 @@ impl AlignQueryable { AlignData::Data(k, (v, ts)) => { query .reply(k, v.payload) - .with_encoding(v.encoding) + .encoding(v.encoding) .timestamp(ts) .res() .await diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs b/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs index 9d5257e53f..6527d54c66 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs @@ -111,7 +111,7 @@ impl Aligner { payload, encoding, .. } = value; let sample = PutSampleBuilder::new(key, payload) - .with_encoding(encoding) + .encoding(encoding) .timestamp(ts) .res_sync(); log::debug!("[ALIGNER] Adding {:?} to storage", sample); diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs index 6d31c9710a..8e60ee320e 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs @@ -315,7 +315,7 @@ impl StorageService { payload, encoding, .. } = data.value; PutSampleBuilder::new(KeyExpr::from(k.clone()), payload) - .with_encoding(encoding) + .encoding(encoding) .timestamp(data.timestamp) .res_sync() } @@ -344,7 +344,7 @@ impl StorageService { .put( stripped_key, Value::new(sample_to_store.payload().clone()) - .with_encoding(sample_to_store.encoding().clone()), + .encoding(sample_to_store.encoding().clone()), *sample_to_store.timestamp().unwrap(), ) .await @@ -532,7 +532,7 @@ impl StorageService { } = entry.value; if let Err(e) = q .reply(key.clone(), payload) - .with_encoding(encoding) + .encoding(encoding) .timestamp(entry.timestamp) .res_async() .await @@ -567,7 +567,7 @@ impl StorageService { } = entry.value; if let Err(e) = q .reply(q.key_expr().clone(), payload) - .with_encoding(encoding) + .encoding(encoding) .timestamp(entry.timestamp) .res_async() .await @@ -719,7 +719,7 @@ fn construct_update(data: String) -> Update { for slice in result.3 { payload.push_zslice(slice.to_vec().into()); } - let value = Value::new(payload).with_encoding(result.2); + let value = Value::new(payload).encoding(result.2); let data = StoredData { value, timestamp: Timestamp::from_str(&result.1).unwrap(), // @TODO: remove the unwrap() diff --git a/zenoh/src/net/runtime/adminspace.rs b/zenoh/src/net/runtime/adminspace.rs index caeeb5c89b..070b3bcd3a 100644 --- a/zenoh/src/net/runtime/adminspace.rs +++ b/zenoh/src/net/runtime/adminspace.rs @@ -426,7 +426,7 @@ impl Primitives for AdminSpace { parameters, value: query .ext_body - .map(|b| Value::from(b.payload).with_encoding(b.encoding)), + .map(|b| Value::from(b.payload).encoding(b.encoding)), qid: msg.id, zid, primitives, @@ -578,7 +578,7 @@ fn router_data(context: &AdminContext, query: Query) { }; if let Err(e) = query .reply(reply_key, payload) - .with_encoding(Encoding::APPLICATION_JSON) + .encoding(Encoding::APPLICATION_JSON) .res_sync() { log::error!("Error sending AdminSpace reply: {:?}", e); diff --git a/zenoh/src/publication.rs b/zenoh/src/publication.rs index 0e93350222..8f52d5e4fa 100644 --- a/zenoh/src/publication.rs +++ b/zenoh/src/publication.rs @@ -199,14 +199,14 @@ impl SampleBuilderTrait for DeleteBuilder<'_, '_> { } impl ValueBuilderTrait for PutBuilder<'_, '_> { - fn with_encoding>(self, encoding: T) -> Self { + fn encoding>(self, encoding: T) -> Self { Self { encoding: encoding.into(), ..self } } - fn with_payload(self, payload: IntoPayload) -> Self + fn payload(self, payload: IntoPayload) -> Self where IntoPayload: Into, { @@ -782,14 +782,14 @@ impl SampleBuilderTrait for PutPublication<'_> { } impl ValueBuilderTrait for PutPublication<'_> { - fn with_encoding>(self, encoding: T) -> Self { + fn encoding>(self, encoding: T) -> Self { Self { encoding: encoding.into(), ..self } } - fn with_payload(self, payload: IntoPayload) -> Self + fn payload(self, payload: IntoPayload) -> Self where IntoPayload: Into, { diff --git a/zenoh/src/query.rs b/zenoh/src/query.rs index 05f9a3557f..837ed69f22 100644 --- a/zenoh/src/query.rs +++ b/zenoh/src/query.rs @@ -169,13 +169,13 @@ impl QoSBuilderTrait for GetBuilder<'_, '_, DefaultHandler> { } impl ValueBuilderTrait for GetBuilder<'_, '_, Handler> { - fn with_encoding>(self, encoding: T) -> Self { - let value = Some(self.value.unwrap_or_default().with_encoding(encoding)); + fn encoding>(self, encoding: T) -> Self { + let value = Some(self.value.unwrap_or_default().encoding(encoding)); Self { value, ..self } } - fn with_payload>(self, payload: T) -> Self { - let value = Some(self.value.unwrap_or_default().with_payload(payload)); + fn payload>(self, payload: T) -> Self { + let value = Some(self.value.unwrap_or_default().payload(payload)); Self { value, ..self } } } diff --git a/zenoh/src/queryable.rs b/zenoh/src/queryable.rs index 4f478e1ce7..37f914d0e0 100644 --- a/zenoh/src/queryable.rs +++ b/zenoh/src/queryable.rs @@ -228,7 +228,7 @@ impl<'a> ReplySampleBuilder<'a> { query: self.query, sample_builder: self.sample_builder.into(), }; - builder.with_payload(payload) + builder.payload(payload) } pub fn delete(self) -> ReplyDelBuilder<'a> { ReplyDelBuilder { @@ -366,16 +366,16 @@ impl QoSBuilderTrait for ReplyBuilder<'_> { } impl ValueBuilderTrait for ReplyBuilder<'_> { - fn with_encoding>(self, encoding: T) -> Self { + fn encoding>(self, encoding: T) -> Self { Self { - sample_builder: self.sample_builder.with_encoding(encoding), + sample_builder: self.sample_builder.encoding(encoding), ..self } } - fn with_payload>(self, payload: T) -> Self { + fn payload>(self, payload: T) -> Self { Self { - sample_builder: self.sample_builder.with_payload(payload), + sample_builder: self.sample_builder.payload(payload), ..self } } diff --git a/zenoh/src/sample.rs b/zenoh/src/sample.rs index 163ae2090a..813bc1c63e 100644 --- a/zenoh/src/sample.rs +++ b/zenoh/src/sample.rs @@ -570,7 +570,7 @@ impl Sample { impl From for Value { fn from(sample: Sample) -> Self { - Value::new(sample.payload).with_encoding(sample.encoding) + Value::new(sample.payload).encoding(sample.encoding) } } diff --git a/zenoh/src/sample_builder.rs b/zenoh/src/sample_builder.rs index a113a9c953..0996f17cf9 100644 --- a/zenoh/src/sample_builder.rs +++ b/zenoh/src/sample_builder.rs @@ -56,9 +56,9 @@ pub trait SampleBuilderTrait { pub trait ValueBuilderTrait { /// Set the [`Encoding`] - fn with_encoding>(self, encoding: T) -> Self; + fn encoding>(self, encoding: T) -> Self; /// Sets the payload - fn with_payload>(self, payload: T) -> Self; + fn payload>(self, payload: T) -> Self; } #[derive(Debug)] @@ -213,13 +213,13 @@ impl QoSBuilderTrait for PutSampleBuilder { } impl ValueBuilderTrait for PutSampleBuilder { - fn with_encoding>(self, encoding: T) -> Self { + fn encoding>(self, encoding: T) -> Self { Self(SampleBuilder(Sample { encoding: encoding.into(), ..self.0 .0 })) } - fn with_payload>(self, payload: T) -> Self { + fn payload>(self, payload: T) -> Self { Self(SampleBuilder(Sample { payload: payload.into(), ..self.0 .0 diff --git a/zenoh/src/value.rs b/zenoh/src/value.rs index 2e288c64ad..6d4de1366c 100644 --- a/zenoh/src/value.rs +++ b/zenoh/src/value.rs @@ -46,13 +46,13 @@ impl Value { } impl ValueBuilderTrait for Value { - fn with_encoding>(self, encoding: T) -> Self { + fn encoding>(self, encoding: T) -> Self { Self { encoding: encoding.into(), ..self } } - fn with_payload>(self, payload: T) -> Self { + fn payload>(self, payload: T) -> Self { Self { payload: payload.into(), ..self