diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs index de76ade51d..6d31c9710a 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs @@ -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.into()); + let value = Value::new(payload).with_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 9047e8b112..caeeb5c89b 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.into())), + .map(|b| Value::from(b.payload).with_encoding(b.encoding)), qid: msg.id, zid, primitives, diff --git a/zenoh/src/publication.rs b/zenoh/src/publication.rs index cd68530bf7..0e93350222 100644 --- a/zenoh/src/publication.rs +++ b/zenoh/src/publication.rs @@ -199,8 +199,11 @@ impl SampleBuilderTrait for DeleteBuilder<'_, '_> { } impl ValueBuilderTrait for PutBuilder<'_, '_> { - fn with_encoding(self, encoding: Encoding) -> Self { - Self { encoding, ..self } + fn with_encoding>(self, encoding: T) -> Self { + Self { + encoding: encoding.into(), + ..self + } } fn with_payload(self, payload: IntoPayload) -> Self @@ -779,8 +782,11 @@ impl SampleBuilderTrait for PutPublication<'_> { } impl ValueBuilderTrait for PutPublication<'_> { - fn with_encoding(self, encoding: Encoding) -> Self { - Self { encoding, ..self } + fn with_encoding>(self, encoding: T) -> Self { + Self { + encoding: encoding.into(), + ..self + } } fn with_payload(self, payload: IntoPayload) -> Self diff --git a/zenoh/src/query.rs b/zenoh/src/query.rs index 2d4e5e1ee3..05f9a3557f 100644 --- a/zenoh/src/query.rs +++ b/zenoh/src/query.rs @@ -169,15 +169,12 @@ impl QoSBuilderTrait for GetBuilder<'_, '_, DefaultHandler> { } impl ValueBuilderTrait for GetBuilder<'_, '_, Handler> { - fn with_encoding(self, encoding: Encoding) -> Self { + fn with_encoding>(self, encoding: T) -> Self { let value = Some(self.value.unwrap_or_default().with_encoding(encoding)); Self { value, ..self } } - fn with_payload(self, payload: IntoPayload) -> Self - where - IntoPayload: Into, - { + fn with_payload>(self, payload: T) -> Self { let value = Some(self.value.unwrap_or_default().with_payload(payload)); Self { value, ..self } } diff --git a/zenoh/src/queryable.rs b/zenoh/src/queryable.rs index 66cb34459b..4f478e1ce7 100644 --- a/zenoh/src/queryable.rs +++ b/zenoh/src/queryable.rs @@ -366,17 +366,14 @@ impl QoSBuilderTrait for ReplyBuilder<'_> { } impl ValueBuilderTrait for ReplyBuilder<'_> { - fn with_encoding(self, encoding: Encoding) -> Self { + fn with_encoding>(self, encoding: T) -> Self { Self { sample_builder: self.sample_builder.with_encoding(encoding), ..self } } - fn with_payload(self, payload: IntoPayload) -> Self - where - IntoPayload: Into, - { + fn with_payload>(self, payload: T) -> Self { Self { sample_builder: self.sample_builder.with_payload(payload), ..self diff --git a/zenoh/src/sample_builder.rs b/zenoh/src/sample_builder.rs index 2d7277506d..a113a9c953 100644 --- a/zenoh/src/sample_builder.rs +++ b/zenoh/src/sample_builder.rs @@ -41,7 +41,7 @@ pub trait QoSBuilderTrait { } pub trait TimestampBuilderTrait { - /// Sets of clears timestamp + /// Sets of clears timestamp fn timestamp>>(self, timestamp: T) -> Self; } @@ -56,11 +56,9 @@ pub trait SampleBuilderTrait { pub trait ValueBuilderTrait { /// Set the [`Encoding`] - fn with_encoding(self, encoding: Encoding) -> Self; + fn with_encoding>(self, encoding: T) -> Self; /// Sets the payload - fn with_payload(self, payload: IntoPayload) -> Self - where - IntoPayload: Into; + fn with_payload>(self, payload: T) -> Self; } #[derive(Debug)] @@ -215,16 +213,13 @@ impl QoSBuilderTrait for PutSampleBuilder { } impl ValueBuilderTrait for PutSampleBuilder { - fn with_encoding(self, encoding: Encoding) -> Self { + fn with_encoding>(self, encoding: T) -> Self { Self(SampleBuilder(Sample { - encoding, + encoding: encoding.into(), ..self.0 .0 })) } - fn with_payload(self, payload: IntoPayload) -> Self - where - IntoPayload: Into, - { + fn with_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 2d98cbf398..2e288c64ad 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: Encoding) -> Self { - Self { encoding, ..self } + fn with_encoding>(self, encoding: T) -> Self { + Self { + encoding: encoding.into(), + ..self + } } - fn with_payload(self, payload: IntoPayload) -> Self - where - IntoPayload: Into, - { + fn with_payload>(self, payload: T) -> Self { Self { payload: payload.into(), ..self