{"id":21586050,"url":"https://github.com/magiclen/cidr-utils","last_synced_at":"2025-04-09T18:21:36.078Z","repository":{"id":34638851,"uuid":"181253427","full_name":"magiclen/cidr-utils","owner":"magiclen","description":"This crate provides functions for working with IPv4 CIDRs and IPv6 CIDRs.","archived":false,"fork":false,"pushed_at":"2023-11-29T12:40:38.000Z","size":117,"stargazers_count":32,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T16:08:29.404Z","etag":null,"topics":["cidr","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/magiclen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-14T02:59:21.000Z","updated_at":"2024-06-22T20:23:27.000Z","dependencies_parsed_at":"2024-06-19T10:07:36.017Z","dependency_job_id":null,"html_url":"https://github.com/magiclen/cidr-utils","commit_stats":{"total_commits":69,"total_committers":9,"mean_commits":7.666666666666667,"dds":0.1594202898550725,"last_synced_commit":"8602818f4fdd07d7fdbf488e4448fe1cdb3c5c4f"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fcidr-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fcidr-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fcidr-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fcidr-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/cidr-utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085564,"owners_count":21045180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cidr","rust"],"created_at":"2024-11-24T15:12:30.151Z","updated_at":"2025-04-09T18:21:36.050Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"CIDR Utils\n====================\n\n[![CI](https://github.com/magiclen/cidr-utils/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/cidr-utils/actions/workflows/ci.yml)\n\nThis crate provides functions for working with IPv4 CIDRs and IPv6 CIDRs.\n\n## Examples\n\nCombine subnetworks to supernetworks.\n\n```rust\nuse std::str::FromStr;\n\nuse cidr::Ipv4Cidr;\nuse cidr_utils::Ipv4CidrSize;\nuse cidr_utils::combiner::Ipv4CidrCombiner;\n\nlet mut combiner = Ipv4CidrCombiner::new();\n\ncombiner.push(Ipv4Cidr::from_str(\"192.168.51.100\").unwrap());\n\nassert_eq!(1, combiner.len());\nassert_eq!(\"192.168.51.100\".to_string(), combiner[0].to_string());\n\ncombiner.push(Ipv4Cidr::from_str(\"192.168.51.101\").unwrap());\n\nassert_eq!(1, combiner.len());\nassert_eq!(\"192.168.51.100/31\".to_string(), combiner[0].to_string());\n\ncombiner.push(Ipv4Cidr::from_str(\"192.168.51.102\").unwrap());\n\nassert_eq!(2, combiner.len());\nassert_eq!(\"192.168.51.100/31\".to_string(), combiner[0].to_string());\nassert_eq!(\"192.168.51.102\".to_string(), combiner[1].to_string());\n\ncombiner.push(Ipv4Cidr::from_str(\"192.168.51.103\").unwrap());\n\nassert_eq!(1, combiner.len());\nassert_eq!(\"192.168.51.100/30\".to_string(), combiner[0].to_string());\n\nassert_eq!(true, combiner.contains(\u0026[192, 168, 51, 102].into()));\nassert_eq!(false, combiner.contains(\u0026[192, 168, 51, 105].into()));\n\nassert_eq!(4, combiner.size());\n```\n\nSeparate a network into subnetworks.\n\n```rust\nuse std::str::FromStr;\n\nuse cidr::Ipv4Cidr;\nuse cidr_utils::Ipv4CidrSize;\nuse cidr_utils::separator::Ipv4CidrSeparator;\n\nlet cidr = Ipv4Cidr::from_str(\"192.168.56.0/24\").unwrap();\n\nlet result = Ipv4CidrSeparator::divide_by(\u0026cidr, 4).unwrap();\n\nassert_eq!(4, result.len());\nassert_eq!(64, result[0].size());\nassert_eq!(64, result[1].size());\nassert_eq!(64, result[2].size());\nassert_eq!(64, result[3].size());\n\nassert_eq!(\"[192.168.56.0/26]\".to_string(), result[0].to_string());\nassert_eq!(\"[192.168.56.64/26]\".to_string(), result[1].to_string());\nassert_eq!(\"[192.168.56.128/26]\".to_string(), result[2].to_string());\nassert_eq!(\"[192.168.56.192/26]\".to_string(), result[3].to_string());\n\nlet result = Ipv4CidrSeparator::divide_by(\u0026cidr, 5).unwrap();\n\nassert_eq!(5, result.len());\nassert_eq!(51, result[0].size());\nassert_eq!(51, result[1].size());\nassert_eq!(51, result[2].size());\nassert_eq!(51, result[3].size());\nassert_eq!(52, result[4].size());\n\nassert_eq!(\"[192.168.56.0/27, 192.168.56.32/28, 192.168.56.48/31, 192.168.56.50/32]\".to_string(), result[0].to_string());\nassert_eq!(\"[192.168.56.51/32, 192.168.56.52/30, 192.168.56.56/29, 192.168.56.64/27, 192.168.56.96/30, 192.168.56.100/31]\".to_string(), result[1].to_string());\nassert_eq!(\"[192.168.56.102/31, 192.168.56.104/29, 192.168.56.112/28, 192.168.56.128/28, 192.168.56.144/29, 192.168.56.152/32]\".to_string(), result[2].to_string());\nassert_eq!(\"[192.168.56.153/32, 192.168.56.154/31, 192.168.56.156/30, 192.168.56.160/27, 192.168.56.192/29, 192.168.56.200/30]\".to_string(), result[3].to_string());\nassert_eq!(\"[192.168.56.204/30, 192.168.56.208/28, 192.168.56.224/27]\".to_string(), result[4].to_string());\n\nlet result = Ipv4CidrSeparator::sub_networks(\u0026cidr, 26).unwrap();\n\nassert_eq!(4, result.len());\nassert_eq!(64, result[0].size());\nassert_eq!(64, result[1].size());\nassert_eq!(64, result[2].size());\nassert_eq!(64, result[3].size());\n\nassert_eq!(\"192.168.56.0/26\".to_string(), result[0].to_string());\nassert_eq!(\"192.168.56.64/26\".to_string(), result[1].to_string());\nassert_eq!(\"192.168.56.128/26\".to_string(), result[2].to_string());\nassert_eq!(\"192.168.56.192/26\".to_string(), result[3].to_string());\n```\n\n## Crates.io\n\nhttps://crates.io/crates/cidr-utils\n\n## Documentation\n\nhttps://docs.rs/cidr-utils\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fcidr-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fcidr-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fcidr-utils/lists"}