@@ -15,6 +15,7 @@ pub trait Mdns {
15
15
/// NOTE: This trait might change once `rs-matter` starts supporting mDNS resolvers
16
16
async fn run < U > (
17
17
& mut self ,
18
+ matter : & Matter < ' _ > ,
18
19
udp : U ,
19
20
mac : & [ u8 ] ,
20
21
ipv4 : Ipv4Addr ,
31
32
{
32
33
async fn run < U > (
33
34
& mut self ,
35
+ matter : & Matter < ' _ > ,
34
36
udp : U ,
35
37
mac : & [ u8 ] ,
36
38
ipv4 : Ipv4Addr ,
@@ -40,24 +42,14 @@ where
40
42
where
41
43
U : UdpBind ,
42
44
{
43
- ( * self ) . run ( udp, mac, ipv4, ipv6, interface) . await
45
+ ( * self ) . run ( matter , udp, mac, ipv4, ipv6, interface) . await
44
46
}
45
47
}
46
48
47
49
/// A built-in mDNS responder for Matter, utilizing the `rs-matter` built-in mDNS implementation.
48
- pub struct BuiltinMdns < ' a > {
49
- matter : & ' a Matter < ' a > ,
50
- }
51
-
52
- impl < ' a > BuiltinMdns < ' a > {
53
- /// Create a new instance of the built-in mDNS responder.
54
- ///
55
- /// # Arguments
56
- /// * `matter` - A reference to the Matter instance that this responder will use.
57
- pub const fn new ( matter : & ' a Matter < ' a > ) -> Self {
58
- Self { matter }
59
- }
50
+ pub struct BuiltinMdns ;
60
51
52
+ impl BuiltinMdns {
61
53
/// A utility to prep and run the built-in `rs-matter` mDNS responder for Matter via the `edge-nal` UDP traits.
62
54
///
63
55
/// Arguments:
@@ -69,6 +61,7 @@ impl<'a> BuiltinMdns<'a> {
69
61
/// - `interface`: The interface index for the host, used for IPv6 multicast.
70
62
pub async fn run < U > (
71
63
& mut self ,
64
+ matter : & Matter < ' _ > ,
72
65
udp : U ,
73
66
mac : & [ u8 ] ,
74
67
ipv4 : Ipv4Addr ,
@@ -137,7 +130,7 @@ impl<'a> BuiltinMdns<'a> {
137
130
panic ! ( "Invalid MAC address length: should be 6 or 8 bytes" ) ;
138
131
}
139
132
140
- BuiltinMdnsResponder :: new ( self . matter )
133
+ BuiltinMdnsResponder :: new ( matter)
141
134
. run (
142
135
udp:: Udp ( send) ,
143
136
udp:: Udp ( recv) ,
@@ -156,9 +149,10 @@ impl<'a> BuiltinMdns<'a> {
156
149
}
157
150
}
158
151
159
- impl Mdns for BuiltinMdns < ' _ > {
152
+ impl Mdns for BuiltinMdns {
160
153
async fn run < U > (
161
154
& mut self ,
155
+ matter : & Matter < ' _ > ,
162
156
udp : U ,
163
157
mac : & [ u8 ] ,
164
158
ipv4 : Ipv4Addr ,
@@ -168,35 +162,29 @@ impl Mdns for BuiltinMdns<'_> {
168
162
where
169
163
U : UdpBind ,
170
164
{
171
- self . run ( udp, mac, ipv4, ipv6, interface) . await
165
+ self . run ( matter , udp, mac, ipv4, ipv6, interface) . await
172
166
}
173
167
}
174
168
175
169
/// An mDNS responder for Matter using the Avahi zbus mDNS implementation.
176
170
#[ cfg( feature = "zbus" ) ]
177
171
pub struct AvahiMdns < ' a > {
178
- matter : & ' a Matter < ' a > ,
179
172
connection : & ' a rs_matter:: utils:: zbus:: Connection ,
180
173
}
181
174
182
175
#[ cfg( feature = "zbus" ) ]
183
176
impl < ' a > AvahiMdns < ' a > {
184
177
/// Create a new instance of the Avahi mDNS responder.
185
- ///
186
- /// # Arguments
187
- /// * `matter` - A reference to the Matter instance that this responder will use.
188
- pub const fn new (
189
- matter : & ' a Matter < ' a > ,
190
- connection : & ' a rs_matter:: utils:: zbus:: Connection ,
191
- ) -> Self {
192
- Self { matter, connection }
178
+ pub const fn new ( connection : & ' a rs_matter:: utils:: zbus:: Connection ) -> Self {
179
+ Self { connection }
193
180
}
194
181
}
195
182
196
183
#[ cfg( feature = "zbus" ) ]
197
184
impl Mdns for AvahiMdns < ' _ > {
198
185
async fn run < U > (
199
186
& mut self ,
187
+ matter : & Matter < ' _ > ,
200
188
_udp : U ,
201
189
_mac : & [ u8 ] ,
202
190
_ipv4 : Ipv4Addr ,
@@ -206,7 +194,7 @@ impl Mdns for AvahiMdns<'_> {
206
194
where
207
195
U : UdpBind ,
208
196
{
209
- rs_matter:: transport:: network:: mdns:: avahi:: AvahiMdnsResponder :: new ( self . matter )
197
+ rs_matter:: transport:: network:: mdns:: avahi:: AvahiMdnsResponder :: new ( matter)
210
198
. run ( self . connection )
211
199
. await
212
200
}
@@ -215,28 +203,22 @@ impl Mdns for AvahiMdns<'_> {
215
203
/// An mDNS responder for Matter using the systemd-resolved zbus mDNS implementation.
216
204
#[ cfg( feature = "zbus" ) ]
217
205
pub struct ResolveMdns < ' a > {
218
- matter : & ' a Matter < ' a > ,
219
206
connection : & ' a rs_matter:: utils:: zbus:: Connection ,
220
207
}
221
208
222
209
#[ cfg( feature = "zbus" ) ]
223
210
impl < ' a > ResolveMdns < ' a > {
224
211
/// Create a new instance of the systemd-resolved mDNS responder.
225
- ///
226
- /// # Arguments
227
- /// * `matter` - A reference to the Matter instance that this responder will use.
228
- pub const fn new (
229
- matter : & ' a Matter < ' a > ,
230
- connection : & ' a rs_matter:: utils:: zbus:: Connection ,
231
- ) -> Self {
232
- Self { matter, connection }
212
+ pub const fn new ( connection : & ' a rs_matter:: utils:: zbus:: Connection ) -> Self {
213
+ Self { connection }
233
214
}
234
215
}
235
216
236
217
#[ cfg( feature = "zbus" ) ]
237
218
impl Mdns for ResolveMdns < ' _ > {
238
219
async fn run < U > (
239
220
& mut self ,
221
+ matter : & Matter < ' _ > ,
240
222
_udp : U ,
241
223
_mac : & [ u8 ] ,
242
224
_ipv4 : Ipv4Addr ,
@@ -246,33 +228,21 @@ impl Mdns for ResolveMdns<'_> {
246
228
where
247
229
U : UdpBind ,
248
230
{
249
- rs_matter:: transport:: network:: mdns:: resolve:: ResolveMdnsResponder :: new ( self . matter )
231
+ rs_matter:: transport:: network:: mdns:: resolve:: ResolveMdnsResponder :: new ( matter)
250
232
. run ( self . connection )
251
233
. await
252
234
}
253
235
}
254
236
255
237
/// An mDNS responder for Matter using the `zeroconf` crate.
256
238
#[ cfg( feature = "zeroconf" ) ]
257
- pub struct ZeroconfMdns < ' a > {
258
- matter : & ' a Matter < ' a > ,
259
- }
260
-
261
- #[ cfg( feature = "zeroconf" ) ]
262
- impl < ' a > ZeroconfMdns < ' a > {
263
- /// Create a new instance of the `zeroconf` `mDNS responder.
264
- ///
265
- /// # Arguments
266
- /// * `matter` - A reference to the Matter instance that this responder will use.
267
- pub const fn new ( matter : & ' a Matter < ' a > ) -> Self {
268
- Self { matter }
269
- }
270
- }
239
+ pub struct ZeroconfMdns ;
271
240
272
241
#[ cfg( feature = "zeroconf" ) ]
273
- impl Mdns for ZeroconfMdns < ' _ > {
242
+ impl Mdns for ZeroconfMdns {
274
243
async fn run < U > (
275
244
& mut self ,
245
+ matter : & Matter < ' _ > ,
276
246
_udp : U ,
277
247
_mac : & [ u8 ] ,
278
248
_ipv4 : Ipv4Addr ,
@@ -282,33 +252,21 @@ impl Mdns for ZeroconfMdns<'_> {
282
252
where
283
253
U : UdpBind ,
284
254
{
285
- rs_matter:: transport:: network:: mdns:: zeroconf:: ZeroconfMdnsResponder :: new ( self . matter )
255
+ rs_matter:: transport:: network:: mdns:: zeroconf:: ZeroconfMdnsResponder :: new ( matter)
286
256
. run ( )
287
257
. await
288
258
}
289
259
}
290
260
291
261
/// An mDNS responder for Matter using the `astro-dnssd` crate.
292
262
#[ cfg( feature = "astro-dnssd" ) ]
293
- pub struct AstroMdns < ' a > {
294
- matter : & ' a Matter < ' a > ,
295
- }
296
-
297
- #[ cfg( feature = "astro-dnssd" ) ]
298
- impl < ' a > AstroMdns < ' a > {
299
- /// Create a new instance of the `astro-dnssd` `mDNS responder.
300
- ///
301
- /// # Arguments
302
- /// * `matter` - A reference to the Matter instance that this responder will use.
303
- pub const fn new ( matter : & ' a Matter < ' a > ) -> Self {
304
- Self { matter }
305
- }
306
- }
263
+ pub struct AstroMdns ;
307
264
308
265
#[ cfg( feature = "astro-dnssd" ) ]
309
- impl Mdns for AstroMdns < ' _ > {
266
+ impl Mdns for AstroMdns {
310
267
async fn run < U > (
311
268
& mut self ,
269
+ matter : & Matter < ' _ > ,
312
270
_udp : U ,
313
271
_mac : & [ u8 ] ,
314
272
_ipv4 : Ipv4Addr ,
@@ -318,7 +276,7 @@ impl Mdns for AstroMdns<'_> {
318
276
where
319
277
U : UdpBind ,
320
278
{
321
- rs_matter:: transport:: network:: mdns:: astro:: AstroMdnsResponder :: new ( self . matter )
279
+ rs_matter:: transport:: network:: mdns:: astro:: AstroMdnsResponder :: new ( matter)
322
280
. run ( )
323
281
. await
324
282
}
0 commit comments