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:
parent
f546ff2011
commit
3cad9cac57
7 changed files with 113 additions and 83 deletions
21
src/interface.rs
Normal file
21
src/interface.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue