pub struct FetchingSubscriber<Handler> { /* private fields */ }
AdvancedPublisher
and AdvancedSubscriber
instead.Expand description
A Subscriber that will run the given user defined fetch
function at startup.
The user defined fetch
function should fetch some samples and return them through the callback function
(it could typically be a Session::get()). Those samples will be merged with the received publications and made available in the receiver.
Later on, new fetches can be performed again, calling FetchingSubscriber::fetch()
.
A typical usage of the FetchingSubscriber
is to retrieve publications that were made in the past, but stored in some zenoh Storage.
§Examples
use zenoh::Wait;
use zenoh_ext::*;
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let subscriber = session
.declare_subscriber("key/expr")
.fetching( |cb| {
session
.get("key/expr")
.callback(cb)
.wait()
})
.await
.unwrap();
while let Ok(sample) = subscriber.recv_async().await {
println!("Received: {:?}", sample);
}
Implementations§
Source§impl<Handler> FetchingSubscriber<Handler>
impl<Handler> FetchingSubscriber<Handler>
Sourcepub fn undeclare(self) -> impl Resolve<ZResult<()>>
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
pub fn undeclare(self) -> impl Resolve<ZResult<()>>
AdvancedPublisher
and AdvancedSubscriber
instead.Undeclare this FetchingSubscriber
`.
Sourcepub fn key_expr(&self) -> &KeyExpr<'static>
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
pub fn key_expr(&self) -> &KeyExpr<'static>
AdvancedPublisher
and AdvancedSubscriber
instead.Return the key expression of this FetchingSubscriber
Sourcepub fn fetch<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()> + Send + Sync, TryIntoSample>(
&self,
fetch: Fetch,
) -> impl Resolve<ZResult<()>>
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
pub fn fetch<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()> + Send + Sync, TryIntoSample>( &self, fetch: Fetch, ) -> impl Resolve<ZResult<()>>
AdvancedPublisher
and AdvancedSubscriber
instead.Perform an additional fetch
.
The provided fetch
function should fetch some samples and return them through the callback function
(it could typically be a Session::get()). Those samples will be merged with the received publications and made available in the receiver.
§Examples
use zenoh::Wait;
use zenoh_ext::*;
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let mut subscriber = session
.declare_subscriber("key/expr")
.fetching( |cb| {
session
.get("key/expr")
.callback(cb)
.wait()
})
.await
.unwrap();
// perform an additional fetch
subscriber
.fetch( |cb| {
session
.get("key/expr")
.callback(cb)
.wait()
})
.await
.unwrap();
Trait Implementations§
Source§impl<Handler> Deref for FetchingSubscriber<Handler>
impl<Handler> Deref for FetchingSubscriber<Handler>
Auto Trait Implementations§
impl<Handler> Freeze for FetchingSubscriber<Handler>where
Handler: Freeze,
impl<Handler> !RefUnwindSafe for FetchingSubscriber<Handler>
impl<Handler> Send for FetchingSubscriber<Handler>where
Handler: Send,
impl<Handler> Sync for FetchingSubscriber<Handler>where
Handler: Sync,
impl<Handler> Unpin for FetchingSubscriber<Handler>where
Handler: Unpin,
impl<Handler> !UnwindSafe for FetchingSubscriber<Handler>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, A> DynAccess<T> for A
impl<T, A> DynAccess<T> for A
Source§fn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
Access::load
.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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R> Rng for R
impl<R> Rng for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
StandardUniform
distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Source§fn random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
p
of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator
of being
true. Read moreSource§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Source§fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
random
to avoid conflict with the new gen
keyword in Rust 2024.Rng::random
.Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
random_range
Rng::random_range
.Source§impl<R> TryRngCore for R
impl<R> TryRngCore for R
Source§type Error = Infallible
type Error = Infallible
Source§fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>
u32
.Source§fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>
u64
.Source§fn try_fill_bytes(
&mut self,
dst: &mut [u8],
) -> Result<(), <R as TryRngCore>::Error>
fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>
dest
entirely with random data.Source§fn unwrap_err(self) -> UnwrapErr<Self>where
Self: Sized,
fn unwrap_err(self) -> UnwrapErr<Self>where
Self: Sized,
UnwrapErr
wrapper.Source§fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>
UnwrapMut
wrapper.Source§fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>where
Self: Sized,
RngCore
to a RngReadAdapter
.