From 1875148ab6f97374029ca938fb0356cef1e0fbcb Mon Sep 17 00:00:00 2001 From: shellrow <81893184+shellrow@users.noreply.github.com> Date: Sat, 29 Jan 2022 17:47:29 +0900 Subject: [PATCH] Add docs --- src/ip.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ip.rs b/src/ip.rs index 566cf19..74bf7d1 100644 --- a/src/ip.rs +++ b/src/ip.rs @@ -1,13 +1,18 @@ use std::net::{Ipv4Addr, Ipv6Addr}; +/// Structure of IPv4 Network #[derive(Clone, Debug)] pub struct Ipv4Net { + /// IPv4 Address pub addr: Ipv4Addr, + /// Prefix Length pub prefix_len: u8, + /// Network Mask pub netmask: Ipv4Addr, } impl Ipv4Net { + /// Construct a new Ipv4Net instance from IPv4 Address and Prefix Length pub fn new(ipv4_addr: Ipv4Addr, prefix_len: u8) -> Ipv4Net { Ipv4Net { addr: ipv4_addr, @@ -15,6 +20,7 @@ impl Ipv4Net { netmask: prefix_to_ipv4_netmask(prefix_len), } } + /// Construct a new Ipv4Net instance from IPv4 Address and Network Mask pub fn new_with_netmask(ipv4_addr: Ipv4Addr, netmask: Ipv4Addr) -> Ipv4Net { Ipv4Net { addr: ipv4_addr, @@ -24,14 +30,19 @@ impl Ipv4Net { } } +/// Structure of IPv6 Network #[derive(Clone, Debug)] pub struct Ipv6Net { + /// IPv6 Address pub addr: Ipv6Addr, + /// Prefix Length pub prefix_len: u8, + /// Network Mask pub netmask: Ipv6Addr, } impl Ipv6Net { + /// Construct a new Ipv6Net instance from IPv6 Address and Prefix Length pub fn new(ipv6_addr: Ipv6Addr, prefix_len: u8) -> Ipv6Net { Ipv6Net { addr: ipv6_addr, @@ -39,6 +50,7 @@ impl Ipv6Net { netmask: prefix_to_ipv6_netmask(prefix_len), } } + /// Construct a new Ipv6Net instance from IPv6 Address and Network Mask pub fn new_with_netmask(ipv6_addr: Ipv6Addr, netmask: Ipv6Addr) -> Ipv6Net { Ipv6Net { addr: ipv6_addr,