Renamed W5500 -> Device, added an Interface struct that should implement the embedded-nal traits, used it to internalize the mutability of the device

This commit is contained in:
Jonah Dahlquist 2020-11-19 19:28:12 -08:00
commit 3cad9cac57
7 changed files with 113 additions and 83 deletions

21
src/interface.rs Normal file
View file

@ -0,0 +1,21 @@
use bus::{ActiveBus};
use device::Device;
use network::Network;
use core::cell::RefCell;
pub struct Interface<SpiBus: ActiveBus, NetworkImpl: Network> {
pub device: RefCell<Device<SpiBus, NetworkImpl>>,
}
impl<SpiBus: ActiveBus, NetworkImpl: Network> Interface<SpiBus, NetworkImpl> {
fn new(device: Device<SpiBus, NetworkImpl>) -> Self {
Self { device: RefCell::new(device) }
}
}
impl<SpiBus: ActiveBus, NetworkImpl: Network> From<Device<SpiBus, NetworkImpl>> for Interface<SpiBus, NetworkImpl> {
fn from(device: Device<SpiBus, NetworkImpl>) -> Interface<SpiBus, NetworkImpl> {
Interface::<SpiBus, NetworkImpl>::new(device)
}
}