Skip to content
/ rust Public

Official implementation of the IPGen Spec in Rust

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE
Notifications You must be signed in to change notification settings

ipgen/rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust IPGen Library

Official implementation of the IPGen Spec in Rust

Build Status Latest Version Docs

IPGen is a library for generating unique and reproducible IP addresses in Rust. The IP addresses generated by this library are highly unique (depending on your subnet prefix), yet if you pass it the same input it will produce the same IP address. You can also generate the IP addresses using our command line tool.

Getting Started

Add ipgen as a dependency in your Cargo.toml file.

[dependencies]
ipgen = "1"

Use it in your program as follows:-

fn main() -> ipgen::Result<()> {
  // Compute subnet ID
  let subnet = ipgen::subnet("App 1")?; 
  assert_eq!(subnet, "ba3d");
  
  // Or compute an IPv6 address
  // Note you can also pass in an IPv4 network to generate an IPv4
  let network = "fd52:f6b0:3162::/48".parse()?;
  let ip = ipgen::ip("App 1", network)?;
  assert_eq!(ip.to_string(), "fd52:f6b0:3162:46a1:2a4f:89e8:8aed:1327");

  Ok(())
}

About

Official implementation of the IPGen Spec in Rust

Resources

License

MIT, Apache-2.0 licenses found

Licenses found

MIT
LICENSE
Apache-2.0
LICENSE-APACHE

Stars

Watchers

Forks

Packages

No packages published

Languages