14
14
15
15
use std:: {
16
16
convert:: TryFrom ,
17
+ fmt,
17
18
future:: { IntoFuture , Ready } ,
18
19
pin:: Pin ,
19
20
task:: { Context , Poll } ,
@@ -32,9 +33,7 @@ use zenoh_result::{Error, ZResult};
32
33
use {
33
34
crate :: api:: handlers:: { Callback , DefaultHandler , IntoHandler } ,
34
35
crate :: api:: sample:: SourceInfo ,
35
- crate :: api:: Id ,
36
36
zenoh_protocol:: core:: EntityGlobalId ,
37
- zenoh_protocol:: core:: EntityId ,
38
37
} ;
39
38
40
39
use super :: {
@@ -48,7 +47,23 @@ use super::{
48
47
sample:: { DataInfo , Locality , QoS , Sample , SampleFields , SampleKind } ,
49
48
session:: { SessionRef , Undeclarable } ,
50
49
} ;
51
- use crate :: net:: primitives:: Primitives ;
50
+ use crate :: { api:: Id , net:: primitives:: Primitives } ;
51
+
52
+ pub ( crate ) struct PublisherState {
53
+ pub ( crate ) id : Id ,
54
+ pub ( crate ) remote_id : Id ,
55
+ pub ( crate ) key_expr : KeyExpr < ' static > ,
56
+ pub ( crate ) destination : Locality ,
57
+ }
58
+
59
+ impl fmt:: Debug for PublisherState {
60
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
61
+ f. debug_struct ( "Publisher" )
62
+ . field ( "id" , & self . id )
63
+ . field ( "key_expr" , & self . key_expr )
64
+ . finish ( )
65
+ }
66
+ }
52
67
53
68
#[ zenoh_macros:: unstable]
54
69
#[ derive( Clone ) ]
@@ -113,8 +128,7 @@ impl std::fmt::Debug for PublisherRef<'_> {
113
128
#[ derive( Debug , Clone ) ]
114
129
pub struct Publisher < ' a > {
115
130
pub ( crate ) session : SessionRef < ' a > ,
116
- #[ cfg( feature = "unstable" ) ]
117
- pub ( crate ) eid : EntityId ,
131
+ pub ( crate ) id : Id ,
118
132
pub ( crate ) key_expr : KeyExpr < ' a > ,
119
133
pub ( crate ) congestion_control : CongestionControl ,
120
134
pub ( crate ) priority : Priority ,
@@ -142,7 +156,7 @@ impl<'a> Publisher<'a> {
142
156
pub fn id ( & self ) -> EntityGlobalId {
143
157
EntityGlobalId {
144
158
zid : self . session . zid ( ) ,
145
- eid : self . eid ,
159
+ eid : self . id ,
146
160
}
147
161
}
148
162
@@ -459,11 +473,9 @@ impl Resolvable for PublisherUndeclaration<'_> {
459
473
impl Wait for PublisherUndeclaration < ' _ > {
460
474
fn wait ( mut self ) -> <Self as Resolvable >:: To {
461
475
let Publisher {
462
- session, key_expr , ..
476
+ session, id : eid , ..
463
477
} = & self . publisher ;
464
- session
465
- . undeclare_publication_intent ( key_expr. clone ( ) )
466
- . wait ( ) ?;
478
+ session. undeclare_publisher_inner ( * eid) ?;
467
479
self . publisher . key_expr = unsafe { keyexpr:: from_str_unchecked ( "" ) } . into ( ) ;
468
480
Ok ( ( ) )
469
481
}
@@ -481,10 +493,7 @@ impl IntoFuture for PublisherUndeclaration<'_> {
481
493
impl Drop for Publisher < ' _ > {
482
494
fn drop ( & mut self ) {
483
495
if !self . key_expr . is_empty ( ) {
484
- let _ = self
485
- . session
486
- . undeclare_publication_intent ( self . key_expr . clone ( ) )
487
- . wait ( ) ;
496
+ let _ = self . session . undeclare_publisher_inner ( self . id ) ;
488
497
}
489
498
}
490
499
}
0 commit comments