Skip to content

Commit

Permalink
remove Publisher::write (#819)
Browse files Browse the repository at this point in the history
* build plugins with default zenoh features

* update documentation to the new api for keformat's generated Parsed (#783)

* fix: Relax dependency requirements (#758)

- async-io
- unix-named-pipe
- filepath
- advisory-lock

* feat: Improve release workflow (#756)

* wip: Improve Release workflow

* feat: Add DockerHub & GHCR releases

* feat: Refactor checks and tests into pre-release workflow

* chore: Remove crates_check.sh and crates_publish.sh

* fix: Remove Dockerfile

* restore SN in case of frame drops caused by congestion control (#815)

* remove Publisher::write

* test fix

* remove unrelated changes added by rebasing

---------

Co-authored-by: Pierre Avital <[email protected]>
Co-authored-by: Mahmoud Mazouz <[email protected]>
Co-authored-by: Dmitrii Bannov <[email protected]>
  • Loading branch information
4 people authored Mar 13, 2024
1 parent e06b46d commit cc68ffb
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions zenoh/src/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,25 +350,6 @@ impl<'a> Publisher<'a> {
}
}

/// Send data with [`kind`](SampleKind) (Put or Delete).
///
/// # Examples
/// ```
/// # async_std::task::block_on(async {
/// use zenoh::prelude::r#async::*;
///
/// let session = zenoh::open(config::peer()).res().await.unwrap().into_arc();
/// let publisher = session.declare_publisher("key/expression").res().await.unwrap();
/// publisher.write(SampleKind::Put, "payload").res().await.unwrap();
/// # })
/// ```
pub fn write<IntoPayload>(&self, kind: SampleKind, value: IntoPayload) -> Publication
where
IntoPayload: Into<Payload>,
{
self._write(kind, value.into())
}

/// Put data.
///
/// # Examples
Expand Down Expand Up @@ -1451,11 +1432,17 @@ mod tests {
let session = open(Config::default()).res().unwrap();
let sub = session.declare_subscriber(KEY_EXPR).res().unwrap();
let pub_ = session.declare_publisher(KEY_EXPR).res().unwrap();
pub_.write(kind, VALUE).res().unwrap();

match kind {
SampleKind::Put => pub_.put(VALUE).res().unwrap(),
SampleKind::Delete => pub_.delete().res().unwrap(),
}
let sample = sub.recv().unwrap();

assert_eq!(sample.kind, kind);
assert_eq!(sample.payload.deserialize::<String>().unwrap(), VALUE);
if let SampleKind::Put = kind {
assert_eq!(sample.payload.deserialize::<String>().unwrap(), VALUE);
}
}

sample_kind_integrity_in_publication_with(SampleKind::Put);
Expand Down

0 comments on commit cc68ffb

Please sign in to comment.