Skip to content

Commit 8005ae2

Browse files
milyingmartin82
authored andcommitted
make reliability feature unstable (eclipse-zenoh#1317)
* make reliability feature unstable * clippy fix
1 parent 66f2b7d commit 8005ae2

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

zenoh/src/api/session.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ use zenoh_protocol::network::{
3939
use zenoh_protocol::{
4040
core::{
4141
key_expr::{keyexpr, OwnedKeyExpr},
42-
AtomicExprId, CongestionControl, EntityId, ExprId, Parameters, Reliability, WireExpr,
43-
EMPTY_EXPR_ID,
42+
AtomicExprId, CongestionControl, EntityId, ExprId, Parameters, WireExpr, EMPTY_EXPR_ID,
4443
},
4544
network::{
4645
self,
@@ -102,6 +101,8 @@ use crate::net::{
102101
routing::dispatcher::face::Face,
103102
runtime::{Runtime, RuntimeBuilder},
104103
};
104+
#[cfg(feature = "unstable")]
105+
use crate::pubsub::Reliability;
105106

106107
zconfigurable! {
107108
pub(crate) static ref API_DATA_RECEPTION_CHANNEL_SIZE: usize = 256;
@@ -377,6 +378,7 @@ impl<'s, 'a> SessionDeclarations<'s, 'a> for SessionRef<'a> {
377378
SubscriberBuilder {
378379
session: self.clone(),
379380
key_expr: TryIntoKeyExpr::try_into(key_expr).map_err(Into::into),
381+
#[cfg(feature = "unstable")]
380382
reliability: Reliability::DEFAULT,
381383
origin: Locality::default(),
382384
handler: DefaultHandler::default(),
@@ -2035,6 +2037,7 @@ impl<'s> SessionDeclarations<'s, 'static> for Arc<Session> {
20352037
SubscriberBuilder {
20362038
session: SessionRef::Shared(self.clone()),
20372039
key_expr: key_expr.try_into().map_err(Into::into),
2040+
#[cfg(feature = "unstable")]
20382041
reliability: Reliability::DEFAULT,
20392042
origin: Locality::default(),
20402043
handler: DefaultHandler::default(),

zenoh/src/api/subscriber.rs

+13-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::{
2020
};
2121

2222
use zenoh_core::{Resolvable, Wait};
23-
use zenoh_protocol::{core::Reliability, network::declare::subscriber::ext::SubscriberInfo};
23+
use zenoh_protocol::network::declare::subscriber::ext::SubscriberInfo;
2424
use zenoh_result::ZResult;
2525
#[cfg(feature = "unstable")]
2626
use {zenoh_config::wrappers::EntityGlobalId, zenoh_protocol::core::EntityGlobalIdProto};
@@ -32,6 +32,8 @@ use super::{
3232
session::{SessionRef, UndeclarableSealed},
3333
Id,
3434
};
35+
#[cfg(feature = "unstable")]
36+
use crate::pubsub::Reliability;
3537

3638
pub(crate) struct SubscriberState {
3739
pub(crate) id: Id,
@@ -200,8 +202,6 @@ pub struct SubscriberBuilder<'a, 'b, Handler> {
200202

201203
#[cfg(feature = "unstable")]
202204
pub reliability: Reliability,
203-
#[cfg(not(feature = "unstable"))]
204-
pub(crate) reliability: Reliability,
205205

206206
#[cfg(feature = "unstable")]
207207
pub origin: Locality,
@@ -239,16 +239,16 @@ impl<'a, 'b> SubscriberBuilder<'a, 'b, DefaultHandler> {
239239
let SubscriberBuilder {
240240
session,
241241
key_expr,
242+
#[cfg(feature = "unstable")]
242243
reliability,
243-
244244
origin,
245245
handler: _,
246246
} = self;
247247
SubscriberBuilder {
248248
session,
249249
key_expr,
250+
#[cfg(feature = "unstable")]
250251
reliability,
251-
252252
origin,
253253
handler: callback,
254254
}
@@ -312,13 +312,15 @@ impl<'a, 'b> SubscriberBuilder<'a, 'b, DefaultHandler> {
312312
let SubscriberBuilder {
313313
session,
314314
key_expr,
315+
#[cfg(feature = "unstable")]
315316
reliability,
316317
origin,
317318
handler: _,
318319
} = self;
319320
SubscriberBuilder {
320321
session,
321322
key_expr,
323+
#[cfg(feature = "unstable")]
322324
reliability,
323325
origin,
324326
handler,
@@ -329,20 +331,23 @@ impl<'a, 'b> SubscriberBuilder<'a, 'b, DefaultHandler> {
329331
impl<'a, 'b, Handler> SubscriberBuilder<'a, 'b, Handler> {
330332
/// Change the subscription reliability.
331333
#[inline]
334+
#[zenoh_macros::unstable]
332335
pub fn reliability(mut self, reliability: Reliability) -> Self {
333336
self.reliability = reliability;
334337
self
335338
}
336339

337340
/// Change the subscription reliability to `Reliable`.
338341
#[inline]
342+
#[zenoh_macros::unstable]
339343
pub fn reliable(mut self) -> Self {
340344
self.reliability = Reliability::Reliable;
341345
self
342346
}
343347

344348
/// Change the subscription reliability to `BestEffort`.
345349
#[inline]
350+
#[zenoh_macros::unstable]
346351
pub fn best_effort(mut self) -> Self {
347352
self.reliability = Reliability::BestEffort;
348353
self
@@ -381,9 +386,12 @@ where
381386
&key_expr,
382387
self.origin,
383388
callback,
389+
#[cfg(feature = "unstable")]
384390
&SubscriberInfo {
385391
reliability: self.reliability,
386392
},
393+
#[cfg(not(feature = "unstable"))]
394+
&SubscriberInfo::default(),
387395
)
388396
.map(|sub_state| Subscriber {
389397
subscriber: SubscriberInner {

zenoh/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ pub mod bytes {
230230

231231
/// Pub/sub primitives
232232
pub mod pubsub {
233+
#[zenoh_macros::unstable]
233234
pub use zenoh_protocol::core::Reliability;
234235

235236
#[zenoh_macros::unstable]

zenoh/tests/session.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ use std::{
2121

2222
#[cfg(feature = "internal")]
2323
use zenoh::internal::runtime::{Runtime, RuntimeBuilder};
24+
#[cfg(feature = "unstable")]
25+
use zenoh::pubsub::Reliability;
2426
use zenoh::{
25-
config, key_expr::KeyExpr, prelude::*, pubsub::Reliability, qos::CongestionControl,
26-
sample::SampleKind, Session,
27+
config, key_expr::KeyExpr, prelude::*, qos::CongestionControl, sample::SampleKind, Session,
2728
};
2829
use zenoh_core::ztimeout;
30+
#[cfg(not(feature = "unstable"))]
31+
use zenoh_protocol::core::Reliability;
2932

3033
const TIMEOUT: Duration = Duration::from_secs(60);
3134
const SLEEP: Duration = Duration::from_secs(1);

0 commit comments

Comments
 (0)