11
11
// Contributors:
12
12
// ZettaScale Zenoh Team, <[email protected] >
13
13
//
14
- use std:: { collections:: BTreeMap , future:: IntoFuture , marker :: PhantomData , str:: FromStr } ;
14
+ use std:: { collections:: BTreeMap , future:: IntoFuture , str:: FromStr } ;
15
15
16
16
use zenoh:: {
17
17
config:: ZenohId ,
@@ -88,31 +88,16 @@ impl HistoryConfig {
88
88
}
89
89
}
90
90
91
- #[ derive( Default , Clone , Copy ) ]
92
- pub struct Unconfigured ;
93
- #[ derive( Default , Clone , Copy ) ]
94
- pub struct Configured ;
95
-
96
- #[ derive( Default , Clone , Copy ) ]
91
+ #[ derive( Debug , Default , Clone , Copy ) ]
97
92
/// Configure retransmission.
98
93
#[ zenoh_macros:: unstable]
99
- pub struct RecoveryConfig < T > {
94
+ pub struct RecoveryConfig < const CONFIGURED : bool = true > {
100
95
periodic_queries : Option < Duration > ,
101
- heartbeat : Option < ( ) > ,
102
- phantom : PhantomData < T > ,
103
- }
104
-
105
- impl < T > std:: fmt:: Debug for RecoveryConfig < T > {
106
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
107
- let mut s = f. debug_struct ( "RetransmissionConf" ) ;
108
- s. field ( "periodic_queries" , & self . periodic_queries ) ;
109
- s. field ( "heartbeat" , & self . heartbeat ) ;
110
- s. finish ( )
111
- }
96
+ heartbeat : bool ,
112
97
}
113
98
114
99
#[ zenoh_macros:: unstable]
115
- impl RecoveryConfig < Unconfigured > {
100
+ impl RecoveryConfig < false > {
116
101
/// Enable periodic queries for not yet received Samples and specify their period.
117
102
///
118
103
/// This allows to retrieve the last Sample(s) if the last Sample(s) is/are lost.
@@ -123,11 +108,10 @@ impl RecoveryConfig<Unconfigured> {
123
108
/// [`sample_miss_detection`](crate::AdvancedPublisherBuilder::sample_miss_detection).
124
109
#[ zenoh_macros:: unstable]
125
110
#[ inline]
126
- pub fn periodic_queries ( self , period : Duration ) -> RecoveryConfig < Configured > {
111
+ pub fn periodic_queries ( self , period : Duration ) -> RecoveryConfig < true > {
127
112
RecoveryConfig {
128
113
periodic_queries : Some ( period) ,
129
- heartbeat : None ,
130
- phantom : PhantomData :: < Configured > ,
114
+ heartbeat : false ,
131
115
}
132
116
}
133
117
@@ -141,11 +125,10 @@ impl RecoveryConfig<Unconfigured> {
141
125
/// [`sporadic_heartbeat`](crate::advanced_publisher::MissDetectionConfig::sporadic_heartbeat).
142
126
#[ zenoh_macros:: unstable]
143
127
#[ inline]
144
- pub fn heartbeat ( self ) -> RecoveryConfig < Configured > {
128
+ pub fn heartbeat ( self ) -> RecoveryConfig < true > {
145
129
RecoveryConfig {
146
130
periodic_queries : None ,
147
- heartbeat : Some ( ( ) ) ,
148
- phantom : PhantomData :: < Configured > ,
131
+ heartbeat : true ,
149
132
}
150
133
}
151
134
}
@@ -156,7 +139,7 @@ pub struct AdvancedSubscriberBuilder<'a, 'b, 'c, Handler, const BACKGROUND: bool
156
139
pub ( crate ) session : & ' a Session ,
157
140
pub ( crate ) key_expr : ZResult < KeyExpr < ' b > > ,
158
141
pub ( crate ) origin : Locality ,
159
- pub ( crate ) retransmission : Option < RecoveryConfig < Configured > > ,
142
+ pub ( crate ) retransmission : Option < RecoveryConfig > ,
160
143
pub ( crate ) query_target : QueryTarget ,
161
144
pub ( crate ) query_timeout : Duration ,
162
145
pub ( crate ) history : Option < HistoryConfig > ,
@@ -275,7 +258,7 @@ impl<'a, 'c, Handler, const BACKGROUND: bool>
275
258
/// [`sample_miss_detection`](crate::AdvancedPublisherBuilder::sample_miss_detection).
276
259
#[ zenoh_macros:: unstable]
277
260
#[ inline]
278
- pub fn recovery ( mut self , conf : RecoveryConfig < Configured > ) -> Self {
261
+ pub fn recovery ( mut self , conf : RecoveryConfig ) -> Self {
279
262
self . retransmission = Some ( conf) ;
280
263
self
281
264
}
@@ -1062,7 +1045,7 @@ impl<Handler> AdvancedSubscriber<Handler> {
1062
1045
None
1063
1046
} ;
1064
1047
1065
- let heartbeat_subscriber = if retransmission. is_some_and ( |r| r. heartbeat . is_some ( ) ) {
1048
+ let heartbeat_subscriber = if retransmission. is_some_and ( |r| r. heartbeat ) {
1066
1049
let ke_heartbeat_sub = & key_expr / KE_ADV_PREFIX / KE_PUB / KE_STARSTAR ;
1067
1050
let statesref = statesref. clone ( ) ;
1068
1051
tracing:: debug!(
0 commit comments