Skip to content

Commit f7cf384

Browse files
committed
mDNS: public run methods
1 parent 0b59b71 commit f7cf384

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

src/mdns.rs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl Mdns for BuiltinMdns {
162162
where
163163
U: UdpBind,
164164
{
165-
self.run(matter, udp, mac, ipv4, ipv6, interface).await
165+
Self::run(self, matter, udp, mac, ipv4, ipv6, interface).await
166166
}
167167
}
168168

@@ -178,6 +178,12 @@ impl<'a> AvahiMdns<'a> {
178178
pub const fn new(connection: &'a rs_matter::utils::zbus::Connection) -> Self {
179179
Self { connection }
180180
}
181+
182+
pub async fn run(&mut self, matter: &Matter<'_>) -> Result<(), Error> {
183+
rs_matter::transport::network::mdns::avahi::AvahiMdnsResponder::new(matter)
184+
.run(self.connection)
185+
.await
186+
}
181187
}
182188

183189
#[cfg(feature = "zbus")]
@@ -194,9 +200,7 @@ impl Mdns for AvahiMdns<'_> {
194200
where
195201
U: UdpBind,
196202
{
197-
rs_matter::transport::network::mdns::avahi::AvahiMdnsResponder::new(matter)
198-
.run(self.connection)
199-
.await
203+
Self::run(self, matter).await
200204
}
201205
}
202206

@@ -212,6 +216,12 @@ impl<'a> ResolveMdns<'a> {
212216
pub const fn new(connection: &'a rs_matter::utils::zbus::Connection) -> Self {
213217
Self { connection }
214218
}
219+
220+
pub async fn run(&mut self, matter: &Matter<'_>) -> Result<(), Error> {
221+
rs_matter::transport::network::mdns::resolve::ResolveMdnsResponder::new(matter)
222+
.run(self.connection)
223+
.await
224+
}
215225
}
216226

217227
#[cfg(feature = "zbus")]
@@ -228,16 +238,23 @@ impl Mdns for ResolveMdns<'_> {
228238
where
229239
U: UdpBind,
230240
{
231-
rs_matter::transport::network::mdns::resolve::ResolveMdnsResponder::new(matter)
232-
.run(self.connection)
233-
.await
241+
Self::run(self, matter).await
234242
}
235243
}
236244

237245
/// An mDNS responder for Matter using the `zeroconf` crate.
238246
#[cfg(feature = "zeroconf")]
239247
pub struct ZeroconfMdns;
240248

249+
#[cfg(feature = "zeroconf")]
250+
impl ZeroconfMdns {
251+
pub async fn run(&mut self, matter: &Matter<'_>) -> Result<(), Error> {
252+
rs_matter::transport::network::mdns::zeroconf::ZeroconfMdnsResponder::new(matter)
253+
.run()
254+
.await
255+
}
256+
}
257+
241258
#[cfg(feature = "zeroconf")]
242259
impl Mdns for ZeroconfMdns {
243260
async fn run<U>(
@@ -252,16 +269,23 @@ impl Mdns for ZeroconfMdns {
252269
where
253270
U: UdpBind,
254271
{
255-
rs_matter::transport::network::mdns::zeroconf::ZeroconfMdnsResponder::new(matter)
256-
.run()
257-
.await
272+
Self::run(self, matter).await
258273
}
259274
}
260275

261276
/// An mDNS responder for Matter using the `astro-dnssd` crate.
262277
#[cfg(feature = "astro-dnssd")]
263278
pub struct AstroMdns;
264279

280+
#[cfg(feature = "astro-dnssd")]
281+
impl AstroMdns {
282+
pub async fn run(&mut self, matter: &Matter<'_>) -> Result<(), Error> {
283+
rs_matter::transport::network::mdns::astro::AstroMdnsResponder::new(matter)
284+
.run()
285+
.await
286+
}
287+
}
288+
265289
#[cfg(feature = "astro-dnssd")]
266290
impl Mdns for AstroMdns {
267291
async fn run<U>(
@@ -276,9 +300,7 @@ impl Mdns for AstroMdns {
276300
where
277301
U: UdpBind,
278302
{
279-
rs_matter::transport::network::mdns::astro::AstroMdnsResponder::new(matter)
280-
.run()
281-
.await
303+
Self::run(self, matter).await
282304
}
283305
}
284306

0 commit comments

Comments
 (0)