embassy/embassy-net/src/config/statik.rs

35 lines
666 B
Rust
Raw Normal View History

2021-02-03 05:09:37 +01:00
use smoltcp::time::Instant;
use super::*;
use crate::{Interface, SocketSet};
pub struct StaticConfigurator {
config: Config,
returned: bool,
2021-02-03 05:09:37 +01:00
}
impl StaticConfigurator {
pub fn new(config: Config) -> Self {
Self {
config,
returned: false,
}
2021-02-03 05:09:37 +01:00
}
}
impl Configurator for StaticConfigurator {
fn poll(
&mut self,
_iface: &mut Interface,
_sockets: &mut SocketSet,
_timestamp: Instant,
) -> Event {
if self.returned {
Event::NoChange
} else {
self.returned = true;
Event::Configured(self.config.clone())
}
2021-02-03 05:09:37 +01:00
}
}