| Crates.io | portify |
| lib.rs | portify |
| version | 1.0.1 |
| created_at | 2025-03-11 05:47:52.745125+00 |
| updated_at | 2025-03-11 16:17:09.687107+00 |
| description | Rust library for easy HTTPS/SVCB record support |
| homepage | https://git.capyfro.dev/daniel/portify |
| repository | https://git.capyfro.dev/daniel/portify |
| max_upload_size | |
| id | 1587584 |
| size | 36,203 |
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.
Add the library to your project:
cargo add portify
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);
}