Struct zenoh::publication::Publisher
source · pub struct Publisher<'a> { /* private fields */ }
Expand description
A publisher that allows to send data through a stream.
Publishers are automatically undeclared when dropped.
Examples
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.put("value").res().await.unwrap();
Publisher
implements the Sink
trait which is useful to forward
streams to zenoh.
use futures::StreamExt;
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap().into_arc();
let mut subscriber = session.declare_subscriber("key/expression").res().await.unwrap();
let publisher = session.declare_publisher("another/key/expression").res().await.unwrap();
subscriber.stream().map(Ok).forward(publisher).await.unwrap();
Implementations§
source§impl<'a> Publisher<'a>
impl<'a> Publisher<'a>
pub fn key_expr(&self) -> &KeyExpr<'a>
sourcepub fn congestion_control(self, congestion_control: CongestionControl) -> Self
pub fn congestion_control(self, congestion_control: CongestionControl) -> Self
Change the congestion_control
to apply when routing the data.
sourcepub fn write<IntoValue>(
&self,
kind: SampleKind,
value: IntoValue
) -> Publication<'_>where
IntoValue: Into<Value>,
pub fn write<IntoValue>(
&self,
kind: SampleKind,
value: IntoValue
) -> Publication<'_>where
IntoValue: Into<Value>,
sourcepub fn put<IntoValue>(&self, value: IntoValue) -> Publication<'_>where
IntoValue: Into<Value>,
pub fn put<IntoValue>(&self, value: IntoValue) -> Publication<'_>where
IntoValue: Into<Value>,
Put data.
Examples
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.put("value").res().await.unwrap();
sourcepub fn delete(&self) -> Publication<'_>
pub fn delete(&self) -> Publication<'_>
Delete data.
Examples
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.delete().res().await.unwrap();
sourcepub fn undeclare(self) -> impl Resolve<ZResult<()>> + 'a
pub fn undeclare(self) -> impl Resolve<ZResult<()>> + 'a
Undeclares the Publisher
, informing the network that it needn’t optimize publications for its key expression anymore.
Examples
use zenoh::prelude::r#async::*;
let session = zenoh::open(config::peer()).res().await.unwrap();
let publisher = session.declare_publisher("key/expression").res().await.unwrap();
publisher.undeclare().res().await.unwrap();
Trait Implementations§
source§impl<'a, IntoValue> Sink<IntoValue> for Publisher<'a>where
IntoValue: Into<Value>,
impl<'a, IntoValue> Sink<IntoValue> for Publisher<'a>where
IntoValue: Into<Value>,
§type Error = Box<dyn Error + Sync + Send + 'static, Global>
type Error = Box<dyn Error + Sync + Send + 'static, Global>
The type of value produced by the sink when an error occurs.
source§fn poll_ready(
self: Pin<&mut Self>,
_cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
fn poll_ready(
self: Pin<&mut Self>,
_cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>
Attempts to prepare the
Sink
to receive a value. Read moresource§fn start_send(self: Pin<&mut Self>, item: IntoValue) -> Result<(), Self::Error>
fn start_send(self: Pin<&mut Self>, item: IntoValue) -> Result<(), Self::Error>
Begin the process of sending a value to the sink.
Each call to this function must be preceded by a successful call to
poll_ready
which returned Poll::Ready(Ok(()))
. Read moresource§impl<'a> Undeclarable<(), PublisherUndeclaration<'a>, Result<(), Box<dyn Error + Sync + Send + 'static, Global>>> for Publisher<'a>
impl<'a> Undeclarable<(), PublisherUndeclaration<'a>, Result<(), Box<dyn Error + Sync + Send + 'static, Global>>> for Publisher<'a>
fn undeclare_inner(self, _: ()) -> PublisherUndeclaration<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Publisher<'a>
impl<'a> Send for Publisher<'a>
impl<'a> Sync for Publisher<'a>
impl<'a> Unpin for Publisher<'a>
impl<'a> !UnwindSafe for Publisher<'a>
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T, Item> SinkExt<Item> for Twhere
T: Sink<Item> + ?Sized,
impl<T, Item> SinkExt<Item> for Twhere
T: Sink<Item> + ?Sized,
§fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>where
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Self::Error>,
Self: Sized,
fn with<U, Fut, F, E>(self, f: F) -> With<Self, Item, U, Fut, F>where
F: FnMut(U) -> Fut,
Fut: Future<Output = Result<Item, E>>,
E: From<Self::Error>,
Self: Sized,
Composes a function in front of the sink. Read more
§fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>where
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Self::Error>>,
Self: Sized,
fn with_flat_map<U, St, F>(self, f: F) -> WithFlatMap<Self, Item, U, St, F>where
F: FnMut(U) -> St,
St: Stream<Item = Result<Item, Self::Error>>,
Self: Sized,
Composes a function in front of the sink. Read more
§fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::Error) -> E,
Self: Sized,
fn sink_map_err<E, F>(self, f: F) -> SinkMapErr<Self, F>where
F: FnOnce(Self::Error) -> E,
Self: Sized,
Transforms the error returned by the sink.
§fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>where
Self: Sized,
Self::Error: Into<E>,
fn sink_err_into<E>(self) -> SinkErrInto<Self, Item, E>where
Self: Sized,
Self::Error: Into<E>,
Map this sink’s error to a different error type using the
Into
trait. Read more§fn buffer(self, capacity: usize) -> Buffer<Self, Item>where
Self: Sized,
fn buffer(self, capacity: usize) -> Buffer<Self, Item>where
Self: Sized,
Adds a fixed-size buffer to the current sink. Read more
§fn fanout<Si>(self, other: Si) -> Fanout<Self, Si>where
Self: Sized,
Item: Clone,
Si: Sink<Item, Error = Self::Error>,
fn fanout<Si>(self, other: Si) -> Fanout<Self, Si>where
Self: Sized,
Item: Clone,
Si: Sink<Item, Error = Self::Error>,
Fanout items to multiple sinks. Read more
§fn flush(&mut self) -> Flush<'_, Self, Item>where
Self: Unpin,
fn flush(&mut self) -> Flush<'_, Self, Item>where
Self: Unpin,
Flush the sink, processing all pending items. Read more
§fn send(&mut self, item: Item) -> Send<'_, Self, Item>where
Self: Unpin,
fn send(&mut self, item: Item) -> Send<'_, Self, Item>where
Self: Unpin,
A future that completes after the given item has been fully processed
into the sink, including flushing. Read more
§fn feed(&mut self, item: Item) -> Feed<'_, Self, Item>where
Self: Unpin,
fn feed(&mut self, item: Item) -> Feed<'_, Self, Item>where
Self: Unpin,
A future that completes after the given item has been received
by the sink. Read more
§fn send_all<St, 'a>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St>where
St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
Self: Unpin,
fn send_all<St, 'a>(&'a mut self, stream: &'a mut St) -> SendAll<'a, Self, St>where
St: TryStream<Ok = Item, Error = Self::Error> + Stream + Unpin + ?Sized,
Self: Unpin,
A future that completes after the given stream has been fully processed
into the sink, including flushing. Read more
§fn left_sink<Si2>(self) -> Either<Self, Si2>where
Si2: Sink<Item, Error = Self::Error>,
Self: Sized,
fn left_sink<Si2>(self) -> Either<Self, Si2>where
Si2: Sink<Item, Error = Self::Error>,
Self: Sized,
§fn right_sink<Si1>(self) -> Either<Si1, Self>where
Si1: Sink<Item, Error = Self::Error>,
Self: Sized,
fn right_sink<Si1>(self) -> Either<Si1, Self>where
Si1: Sink<Item, Error = Self::Error>,
Self: Sized,
§fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>where
Self: Unpin,
fn poll_ready_unpin(
&mut self,
cx: &mut Context<'_>
) -> Poll<Result<(), Self::Error>>where
Self: Unpin,
A convenience method for calling [
Sink::poll_ready
] on Unpin
sink types.§fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>where
Self: Unpin,
fn start_send_unpin(&mut self, item: Item) -> Result<(), Self::Error>where
Self: Unpin,
A convenience method for calling [
Sink::start_send
] on Unpin
sink types.