pub trait SubscriberBuilderExt<'a, 'b, Handler> {
type KeySpace;
// Required methods
fn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>
where TryIntoSample: ExtractSample;
fn querying(
self,
) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>;
}
AdvancedPublisher
and AdvancedSubscriber
instead.Expand description
Some extensions to the zenoh::subscriber::SubscriberBuilder
Required Associated Types§
Required Methods§
Sourcefn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>where
TryIntoSample: ExtractSample,
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
fn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>where
TryIntoSample: ExtractSample,
AdvancedPublisher
and AdvancedSubscriber
instead.Create a FetchingSubscriber
.
This operation returns a FetchingSubscriberBuilder
that can be used to finely configure the subscriber.
As soon as built (calling .wait()
or .await
on the FetchingSubscriberBuilder
), the FetchingSubscriber
will run the given fetch
function. The user defined fetch
function should fetch some samples and return them
through the callback function. 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);
}
Sourcefn querying(self) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
fn querying(self) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>
AdvancedPublisher
and AdvancedSubscriber
instead.Create a FetchingSubscriber
that will perform a query (session.get()
) as it’s
This operation returns a QueryingSubscriberBuilder
that can be used to finely configure the subscriber.
As soon as built (calling .wait()
or .await
on the QueryingSubscriberBuilder
), the FetchingSubscriber
will issue a query on a given key expression (by default it uses the same key expression than it subscribes to).
The results of the query 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_ext::*;
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let subscriber = session
.declare_subscriber("key/expr")
.querying()
.await
.unwrap();
while let Ok(sample) = subscriber.recv_async().await {
println!("Received: {:?}", sample);
}
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a, 'b, Handler> SubscriberBuilderExt<'a, 'b, Handler> for SubscriberBuilder<'a, 'b, Handler>
impl<'a, 'b, Handler> SubscriberBuilderExt<'a, 'b, Handler> for SubscriberBuilder<'a, 'b, Handler>
Source§fn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>where
TryIntoSample: ExtractSample,
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
fn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>where
TryIntoSample: ExtractSample,
AdvancedPublisher
and AdvancedSubscriber
instead.Create a FetchingSubscriber
.
This operation returns a FetchingSubscriberBuilder
that can be used to finely configure the subscriber.
As soon as built (calling .wait()
or .await
on the FetchingSubscriberBuilder
), the FetchingSubscriber
will run the given fetch
function. The user defined fetch
function should fetch some samples and return them
through the callback function. 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);
}
Source§fn querying(self) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
fn querying(self) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>
AdvancedPublisher
and AdvancedSubscriber
instead.Create a FetchingSubscriber
that will perform a query (session.get()
) as it’s
This operation returns a QueryingSubscriberBuilder
that can be used to finely configure the subscriber.
As soon as built (calling .wait()
or .await
on the QueryingSubscriberBuilder
), the FetchingSubscriber
will issue a query on a given key expression (by default it uses the same key expression than it subscribes to).
The results of the query 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_ext::*;
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let subscriber = session
.declare_subscriber("key/expr")
.querying()
.await
.unwrap();
while let Ok(sample) = subscriber.recv_async().await {
println!("Received: {:?}", sample);
}
Source§impl<'a, 'b, Handler> SubscriberBuilderExt<'a, 'b, Handler> for LivelinessSubscriberBuilder<'a, 'b, Handler>
impl<'a, 'b, Handler> SubscriberBuilderExt<'a, 'b, Handler> for LivelinessSubscriberBuilder<'a, 'b, Handler>
Source§fn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>where
TryIntoSample: ExtractSample,
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
fn fetching<Fetch: FnOnce(Box<dyn Fn(TryIntoSample) + Send + Sync>) -> ZResult<()>, TryIntoSample>(
self,
fetch: Fetch,
) -> FetchingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler, Fetch, TryIntoSample>where
TryIntoSample: ExtractSample,
AdvancedPublisher
and AdvancedSubscriber
instead.Create a fetching liveliness subscriber (FetchingSubscriber
).
This operation returns a FetchingSubscriberBuilder
that can be used to finely configure the subscriber.
As soon as built (calling .wait()
or .await
on the FetchingSubscriberBuilder
), the FetchingSubscriber
will run the given fetch
function. The user defined fetch
function should fetch some samples and return them
through the callback function. 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 fetching liveliness subscriber is to retrieve existing liveliness tokens while susbcribing to new liveness changes.
§Examples
use zenoh::Wait;
use zenoh_ext::*;
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let subscriber = session
.liveliness()
.declare_subscriber("key/expr")
.fetching( |cb| {
session
.liveliness()
.get("key/expr")
.callback(cb)
.wait()
})
.await
.unwrap();
while let Ok(sample) = subscriber.recv_async().await {
println!("Received: {:?}", sample);
}
Source§fn querying(self) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>
👎Deprecated: Use AdvancedPublisher
and AdvancedSubscriber
instead.
fn querying(self) -> QueryingSubscriberBuilder<'a, 'b, Self::KeySpace, Handler>
AdvancedPublisher
and AdvancedSubscriber
instead.Create a fetching liveliness subscriber (FetchingSubscriber
) that will perform a
This operation returns a QueryingSubscriberBuilder
that can be used to finely configure the subscriber.
As soon as built (calling .wait()
or .await
on the QueryingSubscriberBuilder
), the FetchingSubscriber
will issue a liveliness query on a given key expression (by default it uses the same key expression than it subscribes to).
The results of the query 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 fetching liveliness subscriber is to retrieve existing liveliness tokens while susbcribing to new liveness changes.
§Examples
use zenoh_ext::*;
let session = zenoh::open(zenoh::Config::default()).await.unwrap();
let subscriber = session
.liveliness()
.declare_subscriber("key/expr")
.querying()
.await
.unwrap();
while let Ok(sample) = subscriber.recv_async().await {
println!("Received: {:?}", sample);
}
Source§type KeySpace = LivelinessSpace
type KeySpace = LivelinessSpace
AdvancedPublisher
and AdvancedSubscriber
instead.