From 8ac47ef90fa8e5a27f082cd061779f03f49aee23 Mon Sep 17 00:00:00 2001 From: Michael Watzko Date: Tue, 23 Mar 2021 23:26:42 +0100 Subject: [PATCH] Replace unused Ipv4Addr impl with a pub use embedded_nal::Ipv4Addr --- src/net.rs | 74 +----------------------------------------------------- 1 file changed, 1 insertion(+), 73 deletions(-) diff --git a/src/net.rs b/src/net.rs index c3cc80f..1926c5e 100644 --- a/src/net.rs +++ b/src/net.rs @@ -12,79 +12,7 @@ // TODO remove some of these constructs and use equivalents available from embedded-nal -/// Ipv4Addr address struct. Can be instantiated with `Ipv4Addr::new`. -#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, Default)] -pub struct Ipv4Addr { - /// Octets of the Ipv4Addr address. - pub octets: [u8; 4], -} - -impl Ipv4Addr { - /// Creates a new IPv4 address from four eight-bit octets. - /// - /// The result will represent the IP address `a`.`b`.`c`.`d`. - /// - /// # Examples - /// - /// ``` - /// use w5500::net::Ipv4Addr; - /// - /// let addr = Ipv4Addr::new(127, 0, 0, 1); - /// ``` - #[allow(clippy::many_single_char_names)] - pub const fn new(a: u8, b: u8, c: u8, d: u8) -> Ipv4Addr { - Ipv4Addr { - octets: [a, b, c, d], - } - } - - /// An IPv4 address with the address pointing to localhost: 127.0.0.1. - /// - /// # Examples - /// - /// ``` - /// use w5500::net::Ipv4Addr; - /// - /// let addr = Ipv4Addr::LOCALHOST; - /// assert_eq!(addr, Ipv4Addr::new(127, 0, 0, 1)); - /// ``` - pub const LOCALHOST: Self = Ipv4Addr::new(127, 0, 0, 1); - - /// An IPv4 address representing an unspecified address: 0.0.0.0 - /// - /// # Examples - /// - /// ``` - /// use w5500::net::Ipv4Addr; - /// - /// let addr = Ipv4Addr::UNSPECIFIED; - /// assert_eq!(addr, Ipv4Addr::new(0, 0, 0, 0)); - /// ``` - pub const UNSPECIFIED: Self = Ipv4Addr::new(0, 0, 0, 0); - - /// An IPv4 address representing the broadcast address: 255.255.255.255 - /// - /// # Examples - /// - /// ``` - /// use w5500::net::Ipv4Addr; - /// - /// let addr = Ipv4Addr::BROADCAST; - /// assert_eq!(addr, Ipv4Addr::new(255, 255, 255, 255)); - /// ``` - pub const BROADCAST: Self = Ipv4Addr::new(255, 255, 255, 255); -} - -impl ::core::fmt::Display for Ipv4Addr { - /// String formatter for Ipv4Addr addresses. - fn fmt(&self, fmt: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - write!( - fmt, - "{}.{}.{}.{}", - self.octets[0], self.octets[1], self.octets[2], self.octets[3], - ) - } -} +pub use embedded_nal::Ipv4Addr; /// MAC address struct. Can be instantiated with `MacAddress::new`. ///