Async mDNS / DNS-SD for the embassy runtime — responder, querier, and
discovery on embassy-net, no_std + alloc.
Introduction
hick-embassy is the embassy async driver for the [hick] mDNS family. It
builds on the hick-smoltcp engine, supplying an embassy-net UdpIo
transport, the embassy-time clock bridge, and an async driver future you
spawn as an embassy task.
For the std / hosted runtimes (tokio, smol, compio), use hick-reactor,
hick-compio, or the hick facade instead.
Installation
[]
= "0.1"
Example
Share one MdnsState
between the driver task and the application (via Rc or a &'static
StaticCell):
use MdnsState;
use ;
let state: &'static =
make_static!;
// Advertise a service.
let mut records = new;
records.add_a;
state.register_service.unwrap;
// Bind v4/v6 sockets to :5353 and join the mDNS group(s), then spawn the driver task
// (it enforces the RFC 6762 §11 egress hop-limit 255 itself — pass sockets by &mut):
spawner.must_spawn;
async !
Feature flags
| Feature | Description |
|---|---|
tracing |
Forward structured tracing events from mdns-proto and hick-smoltcp (no-op on bare-metal without a subscriber). |
stats |
Enable no_std-safe atomic counters; read a snapshot via state.stats(). |
defmt |
Emit defmt log events — the idiomatic choice for embassy bare-metal targets. |
Observability
For embassy targets the recommended logging path is defmt combined with
stats:
= { = "0.1", = ["defmt", "stats"] }
Enable defmt to have the driver emit structured log events through the
defmt framework alongside embassy's own logging.
Enable stats and call state.stats() to obtain a
hick_trace::stats::StatsSnapshot:
let snap = state.stats;
// snap.packets_rx, snap.services_active, snap.cache_size, etc.
The tracing feature is available but is a no-op on bare-metal targets that
do not set up a tracing subscriber.
The metrics feature (bridging counters to the metrics facade) requires
std and is not available on embassy bare-metal targets. Use stats + defmt
instead for observability on embedded.
Design
- Single-executor
!Send: noArc, no atomics.MdnsStateholds the engine behind aRefCellplus anembassy_syncwakeSignal; every handle method takes&self, and a borrow never spans an.await. - Dual v4/v6 stack: the driver pumps a
DualUdpover the present sockets and wakes on aselectof either socket's RX-readiness, the next protocol deadline, or a handle signalling new work. - Builds entirely on the
hick-smoltcpengine — embassy supplies only the transport, clock, and the task wrapper.
The hick family
hick (facade) · mdns-proto (Sans-I/O core) · hick-udp (UDP) ·
hick-reactor (tokio / smol driver) · hick-compio (compio driver) ·
hick-smoltcp (smoltcp engine) · hick-embassy (this crate).
License
hick-embassy is under the terms of both the MIT license and the Apache License
(Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2025 Al Liu.