#record #url #port #resolve #hint #svcb #https-svcb

portify

Rust library for easy HTTPS/SVCB record support

2 stable releases

Uses new Rust 2024

new 1.0.1 Mar 11, 2025

#7 in #hint

MIT license

12KB
94 lines

portify

Portify is a simple way to resolve a URL with a port hint in its SVCB or HTTPS record. There's just one public async function: resolve_svcb(url: &Url), which returns an error if either the record is invalid or does not exist. This library is great for improving support of services on non-standard ports, similar to SRV record helpers.

Usage

Add the library to your project:

cargo add portify

Example

use url::Url;

#[tokio::main]
async fn main() {
    let arg = std::env::args().last().unwrap();
    let mut url = Url::parse(&arg).unwrap();
    match portify::resolve_svcb(&url) {
        Ok(u) => url = u,
        Err(_) => println!("Assuming default port for URL")
    }
    println!("{}", url);
}

License

MIT

Dependencies

~6–12MB
~142K SLoC