portify

Crates.ioportify
lib.rsportify
version1.0.1
created_at2025-03-11 05:47:52.745125+00
updated_at2025-03-11 16:17:09.687107+00
descriptionRust library for easy HTTPS/SVCB record support
homepagehttps://git.capyfro.dev/daniel/portify
repositoryhttps://git.capyfro.dev/daniel/portify
max_upload_size
id1587584
size36,203
Daniel Weiland (capyfro)

documentation

README

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

Commit count: 0

cargo fmt