is-ip 0.1.0

Check if a string is an IP address
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 16.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.57 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • hiql/is-ip
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hiql

is-ip

Check if a string is an IP address

Install

[dependencies]
is-ip = "0.1.0"

Usage

use is_ip::{is_ip, is_ipv4, is_ipv6};

is_ip("1:2:3:4:5:6:7:8");
//=> true

is_ip("192.168.0.1");
//=> true

is_ipv4("1:2:3:4:5:6:7:8");
//=> false

API

is_ip(string: &str) -> bool

Check if string is IPv6 or IPv4.

is_ipv4(string: &str) -> bool

Check if string is IPv4.

is_ipv6(string: &str) -> bool

Check if string is IPv6.

ip_version(string: &str) -> Option<u8>

Returns Some(6) if string is IPv6, Some(4) if string is IPv4, or None if string is neither.

use is_ip::ip_version;

ip_version("1:2:3:4:5:6:7:8");
//=> Some(6)

ip_version("192.168.0.1");
//=> Some(4)

ip_version("abc");
//=> None

This lib inspired by is-ip a nodejs package!