Skip to main content

format_ip_addr

Function format_ip_addr 

Source
pub fn format_ip_addr(ip: &IpAddr) -> String
Expand description

Formats an IP address to a string.

Convenience function for formatting an IpAddr directly.

§Arguments

  • ip - The IP address to format

§Returns

The IP address as a string.

§Examples

use malnet_core::utilities::format_ip_addr;
use std::net::{IpAddr, Ipv4Addr};

let ip = IpAddr::V4(Ipv4Addr::new(192, 168, 1, 1));
let ip_str = format_ip_addr(&ip);
assert_eq!(ip_str, "192.168.1.1");