Skip to content
File

Blob: src/rust/net/lib.rs

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