This crate provides [`DynPhy`], [`DynTxToken`], and [`DynRxToken`], which are object-safe versions
of [`smoltcp`]'s [`phy::Device`], [`phy::RxToken`], and [`phy::TxToken`].
These `Dyn*` types are fully-compatible with and blanket-impled over the [`smoltcp`] types. They are
unfortunately only optimistically zero-alloc (i.e. they _may_ allocate depending on closure sizes).
# Examples
The motivating use-case for this functionality is dynamic dispatch over multiple PHY interfaces,
e.g. for packet-switching. This crate makes the following possible:
```rust
use dyn_phy::DynPhy;
use smoltcp::phy;
let mut loopback = phy::Loopback::new(phy::Medium::Ethernet);
let mut fault_test = phy::FaultInjector::new(phy::Loopback::new(phy::Medium::Ethernet), 0);
// This would not be possible with phy::Device as it is not object-safe:
let mut devs = heapless::Vec::<&mut dyn DynPhy, 8>::new();
devs.push(&mut loopback);
devs.push(&mut fault_test);
for dev in &mut devs {
println!("{:?}", dev.capabilities());
}
```
[`smoltcp`]: https://docs.rs/smoltcp
[`phy::Device`]: https://docs.rs/smoltcp/latest/smoltcp/phy/trait.Device.html
[`phy::RxToken`]: https://docs.rs/smoltcp/latest/smoltcp/phy/trait.RxToken.html
[`phy::TxToken`]: https://docs.rs/smoltcp/latest/smoltcp/phy/trait.TxToken.html
[`DynPhy`]: trait.DynPhy.html
[`DynTxToken`]: struct.DynTxToken.html
[`DynRxToken`]: struct.DynRxToken.html