Fix formatting suggestions
This commit is contained in:
parent
0e73584801
commit
a0e4ead512
@ -8,14 +8,14 @@ use crate::error::Error;
|
|||||||
use crate::ALLOWED_PREFIX_LENS;
|
use crate::ALLOWED_PREFIX_LENS;
|
||||||
|
|
||||||
/// Embeds an IPv4 address into an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
/// Embeds an IPv4 address into an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use ipnet::{Ipv6Net};
|
/// # use ipnet::{Ipv6Net};
|
||||||
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
/// use rfc6052::embed_ipv4_addr;
|
/// use rfc6052::embed_ipv4_addr;
|
||||||
///
|
///
|
||||||
/// // An IPv4 address can be embedded into an IPv6 prefix of acceptable length
|
/// // An IPv4 address can be embedded into an IPv6 prefix of acceptable length
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// embed_ipv4_addr(
|
/// embed_ipv4_addr(
|
||||||
@ -24,7 +24,7 @@ use crate::ALLOWED_PREFIX_LENS;
|
|||||||
/// ),
|
/// ),
|
||||||
/// Ok("64:ff9b:c000:0201::".parse::<Ipv6Addr>().unwrap())
|
/// Ok("64:ff9b:c000:0201::".parse::<Ipv6Addr>().unwrap())
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
/// // Using a prefix that is not an RFC-approved length (in this case 66) will fail
|
/// // Using a prefix that is not an RFC-approved length (in this case 66) will fail
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// embed_ipv4_addr(
|
/// embed_ipv4_addr(
|
||||||
@ -47,14 +47,14 @@ pub fn embed_ipv4_addr(ipv4_addr: Ipv4Addr, ipv6_prefix: Ipv6Net) -> Result<Ipv6
|
|||||||
/// Embeds an IPv4 address into an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
/// Embeds an IPv4 address into an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
||||||
///
|
///
|
||||||
/// **Warning:** This function does not check that the prefix length is valid according to the RFC. Use `embed_ipv4_addr` instead.
|
/// **Warning:** This function does not check that the prefix length is valid according to the RFC. Use `embed_ipv4_addr` instead.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use ipnet::{Ipv6Net};
|
/// # use ipnet::{Ipv6Net};
|
||||||
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
/// use rfc6052::embed_ipv4_addr_unchecked;
|
/// use rfc6052::embed_ipv4_addr_unchecked;
|
||||||
///
|
///
|
||||||
/// // Using a prefix that is not an RFC-approved length (in this case 66) will *succeed*
|
/// // Using a prefix that is not an RFC-approved length (in this case 66) will *succeed*
|
||||||
/// // This is *not* the behavior of `embed_ipv4_addr`
|
/// // This is *not* the behavior of `embed_ipv4_addr`
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
|
@ -5,19 +5,19 @@ use std::cmp::max;
|
|||||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
|
|
||||||
/// Extracts an IPv4 address from an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
/// Extracts an IPv4 address from an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
/// use rfc6052::extract_ipv4_addr;
|
/// use rfc6052::extract_ipv4_addr;
|
||||||
///
|
///
|
||||||
/// // An IPv4 address can be extracted from an IPv6 prefix of acceptable length
|
/// // An IPv4 address can be extracted from an IPv6 prefix of acceptable length
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// extract_ipv4_addr_unchecked("64:ff9b:c000:0201::".parse().unwrap(), 32),
|
/// extract_ipv4_addr_unchecked("64:ff9b:c000:0201::".parse().unwrap(), 32),
|
||||||
/// Ok("192.0.2.1".parse::<Ipv4Addr>().unwrap())
|
/// Ok("192.0.2.1".parse::<Ipv4Addr>().unwrap())
|
||||||
/// );
|
/// );
|
||||||
///
|
///
|
||||||
/// // Using a prefix that is not an RFC-approved length (in this case 66) will fail
|
/// // Using a prefix that is not an RFC-approved length (in this case 66) will fail
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
/// extract_ipv4_addr_unchecked("64:ff9b:c000:0201::".parse().unwrap(), 66),
|
/// extract_ipv4_addr_unchecked("64:ff9b:c000:0201::".parse().unwrap(), 66),
|
||||||
@ -37,13 +37,13 @@ pub fn extract_ipv4_addr(ipv6_addr: Ipv6Addr, prefix_length: u8) -> Result<Ipv4A
|
|||||||
/// Extracts an IPv4 address from an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
/// Extracts an IPv4 address from an IPv6 prefix following the method defined in [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
||||||
///
|
///
|
||||||
/// **Warning:** This function does not check that the prefix length is valid according to the RFC. Use `extract_ipv4_addr` instead.
|
/// **Warning:** This function does not check that the prefix length is valid according to the RFC. Use `extract_ipv4_addr` instead.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
/// # use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
/// use rfc6052::extract_ipv4_addr_unchecked;
|
/// use rfc6052::extract_ipv4_addr_unchecked;
|
||||||
///
|
///
|
||||||
/// // Using a prefix that is not an RFC-approved length (in this case 66) will *succeed*
|
/// // Using a prefix that is not an RFC-approved length (in this case 66) will *succeed*
|
||||||
/// // This is *not* the behavior of `extract_ipv4_addr`
|
/// // This is *not* the behavior of `extract_ipv4_addr`
|
||||||
/// assert_eq!(
|
/// assert_eq!(
|
||||||
|
@ -5,16 +5,16 @@
|
|||||||
#![allow(clippy::missing_panics_doc)]
|
#![allow(clippy::missing_panics_doc)]
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
|
|
||||||
mod error;
|
|
||||||
mod embed;
|
mod embed;
|
||||||
|
mod error;
|
||||||
mod extract;
|
mod extract;
|
||||||
pub use embed::{embed_ipv4_addr, embed_ipv4_addr_unchecked};
|
pub use embed::{embed_ipv4_addr, embed_ipv4_addr_unchecked};
|
||||||
pub use error::Error;
|
pub use error::Error;
|
||||||
pub use extract::{extract_ipv4_addr, extract_ipv4_addr_unchecked};
|
pub use extract::{extract_ipv4_addr, extract_ipv4_addr_unchecked};
|
||||||
|
|
||||||
/// All allowed IPv6 prefix lengths according to [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
/// All allowed IPv6 prefix lengths according to [RFC6052 Section 2.2](https://datatracker.ietf.org/doc/html/rfc6052#section-2.2)
|
||||||
///
|
///
|
||||||
/// While any prefix length between 32 and 96 bits can in theory work with this library,
|
/// While any prefix length between 32 and 96 bits can in theory work with this library,
|
||||||
/// the RFC strictly defines a list of allowed IPv6 prefix to be used for embedding IPv4 addresses. They are:
|
/// the RFC strictly defines a list of allowed IPv6 prefix to be used for embedding IPv4 addresses. They are:
|
||||||
/// - 32 bits
|
/// - 32 bits
|
||||||
/// - 40 bits
|
/// - 40 bits
|
||||||
|
Loading…
x
Reference in New Issue
Block a user