Skip to content

Commit

Permalink
feat(network): add Ipv4Addr::LOOPBACK
Browse files Browse the repository at this point in the history
Signed-off-by: Anhad Singh <[email protected]>
  • Loading branch information
Andy-Python-Programmer committed Sep 29, 2023
1 parent 95894c3 commit a46a02f
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ impl Ipv4Addr {
///
/// [RFC 8200 § 2]: https://www.rfc-editor.org/rfc/rfc791#section-3.2
pub const ADDR_SIZE: usize = 4;
/// Broadcast address.
pub const BROADCAST: Self = Self([0xff; Self::ADDR_SIZE]);
/// Loopback address.
pub const LOOPBACK: Self = Self([127, 0, 0, 1]);
// FIXME(andypython): [`Ipv4Addr::NULL`] should not really be used anywhere except for testing.
// Consider removing it to avoid misuse/confusion.
pub const NULL: Self = Self([0; Self::ADDR_SIZE]);

pub fn new(addr: [u8; Self::ADDR_SIZE]) -> Self {
Expand Down

0 comments on commit a46a02f

Please sign in to comment.