@@ -46,22 +46,19 @@ pub struct ShmClientSetBuilder;
46
46
impl ShmClientSetBuilder {
47
47
/// Add client to the storage (without including the default client set)
48
48
#[ zenoh_macros:: unstable_doc]
49
- pub fn with_client (
50
- self ,
51
- id : ProtocolID ,
52
- client : Arc < dyn ShmClient > ,
53
- ) -> ShmClientStorageBuilder {
54
- let clients = BTreeMap :: from ( [ ( id, client) ] ) ;
49
+ pub fn with_client ( self , client : Arc < dyn ShmClient > ) -> ShmClientStorageBuilder {
50
+ let clients = BTreeMap :: from ( [ ( client. id ( ) , client) ] ) ;
55
51
ShmClientStorageBuilder :: new ( clients)
56
52
}
57
53
58
54
/// Add list of clients to the storage (without including the default client set)
59
55
#[ zenoh_macros:: unstable_doc]
60
- pub fn with_clients (
61
- self ,
62
- clients : & [ ( ProtocolID , Arc < dyn ShmClient > ) ] ,
63
- ) -> ShmClientStorageBuilder {
64
- let clients = clients. iter ( ) . cloned ( ) . collect ( ) ;
56
+ pub fn with_clients ( self , clients : & [ Arc < dyn ShmClient > ] ) -> ShmClientStorageBuilder {
57
+ let clients = clients
58
+ . iter ( )
59
+ . cloned ( )
60
+ . map ( |client| ( client. id ( ) , client) )
61
+ . collect ( ) ;
65
62
ShmClientStorageBuilder :: new ( clients)
66
63
}
67
64
@@ -86,7 +83,8 @@ impl ShmClientStorageBuilder {
86
83
87
84
/// Add client to the storage
88
85
#[ zenoh_macros:: unstable_doc]
89
- pub fn with_client ( mut self , id : ProtocolID , client : Arc < dyn ShmClient > ) -> ZResult < Self > {
86
+ pub fn with_client ( mut self , client : Arc < dyn ShmClient > ) -> ZResult < Self > {
87
+ let id = client. id ( ) ;
90
88
match self . clients . entry ( id) {
91
89
std:: collections:: btree_map:: Entry :: Occupied ( occupied) => {
92
90
bail ! ( "Client already exists for id {id}: {:?}!" , occupied)
@@ -100,8 +98,9 @@ impl ShmClientStorageBuilder {
100
98
101
99
/// Add list of clients to the storage
102
100
#[ zenoh_macros:: unstable_doc]
103
- pub fn with_clients ( mut self , clients : & [ ( ProtocolID , Arc < dyn ShmClient > ) ] ) -> Self {
104
- self . clients . extend ( clients. iter ( ) . cloned ( ) ) ;
101
+ pub fn with_clients ( mut self , clients : & [ Arc < dyn ShmClient > ] ) -> Self {
102
+ self . clients
103
+ . extend ( clients. iter ( ) . cloned ( ) . map ( |client| ( client. id ( ) , client) ) ) ;
105
104
self
106
105
}
107
106
0 commit comments