diff --git a/src/socket/dhcpv4.rs b/src/socket/dhcpv4.rs index c60fa89..c166397 100644 --- a/src/socket/dhcpv4.rs +++ b/src/socket/dhcpv4.rs @@ -29,7 +29,7 @@ const PARAMETER_REQUEST_LIST: &[u8] = &[ ]; /// IPv4 configuration data provided by the DHCP server. -#[derive(Debug, Eq, PartialEq)] +#[derive(Debug, Eq, PartialEq, Clone, Copy)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct Config { /// IP address @@ -103,11 +103,11 @@ enum ClientState { /// Return value for the `Dhcpv4Socket::poll` function #[derive(Debug, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub enum Event<'a> { +pub enum Event { /// Configuration has been lost (for example, the lease has expired) Deconfigured, /// Configuration has been newly acquired, or modified. - Configured(&'a Config), + Configured(Config), } #[derive(Debug)] @@ -544,12 +544,12 @@ impl Dhcpv4Socket { /// /// The socket has an internal "configuration changed" flag. If /// set, this function returns the configuration and resets the flag. - pub fn poll(&mut self) -> Option> { + pub fn poll(&mut self) -> Option { if !self.config_changed { None } else if let ClientState::Renewing(state) = &self.state { self.config_changed = false; - Some(Event::Configured(&state.config)) + Some(Event::Configured(state.config)) } else { self.config_changed = false; Some(Event::Deconfigured) @@ -836,7 +836,7 @@ mod test { assert_eq!( s.poll(), - Some(Event::Configured(&Config { + Some(Event::Configured(Config { address: Ipv4Cidr::new(MY_IP, 24), dns_servers: DNS_IPS, router: Some(SERVER_IP),