-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
auto_encoding
method to builder ot set encoding based fro…
…m payload type
- Loading branch information
Showing
12 changed files
with
394 additions
and
289 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
pub(crate) mod encoding; | ||
pub(crate) mod publisher; | ||
pub(crate) mod sample; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use crate::api::encoding::{AutoEncoding, Encoding}; | ||
|
||
pub trait EncodingBuilderTrait { | ||
/// Set the [`Encoding`] | ||
fn encoding<T: Into<Encoding>>(self, encoding: T) -> Self; | ||
} | ||
|
||
pub trait AutoEncodingBuilderTrait<Payload>: EncodingBuilderTrait + Sized | ||
where | ||
Payload: AutoEncoding, | ||
{ | ||
/// Set the [`Encoding`] according to the payload type | ||
fn auto_encoding(self) -> Self { | ||
if let Some(payload) = self.get_payload() { | ||
let encoding = payload.get_encoding(); | ||
return self.encoding(encoding); | ||
} | ||
self | ||
} | ||
#[doc(hidden)] | ||
fn get_payload(&self) -> Option<&Payload>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.