File
Blob: src/rust/net/lib.rs
| 1 | use std::net::IpAddr; |
| 2 | use std::str::FromStr; |
| 3 | |
| 4 | #[cxx::bridge(namespace = "workerd::rust::net")] |
| 5 | mod ffi { |
| 6 | extern "Rust" { |
| 7 | fn canonicalize_ip(input: &str) -> String; |
| 8 | } |
| 9 | } |
| 10 | |
| 11 | #[must_use] |
| 12 | pub fn canonicalize_ip(input: &str) -> String { |
| 13 | IpAddr::from_str(input).map_or(String::new(), |ip| ip.to_string()) |
| 14 | } |