srt-runtime 0.13.0

SRT (Secure Reliable Transport, draft-sharabayko-srt-01) packet codecs, sans-IO HSv5 handshakes, a one-connection link engine, ARQ, TSBPD, LiveCC/FileCC congestion control, optional payload crypto and an optional tokio UDP adapter; no_std core.
Documentation
//! `parse_url` — read the `srt://` URLs operators hand around into the typed
//! [`SrtUrl`]: host and port, `streamid`, `latency`, `mode` and `passphrase`.
//!
//! An absent query key stays unset, so a caller applies only what the URL
//! states over its own handshake configuration. A `passphrase` never appears
//! in `Debug` output.
//!
//! ```text
//! cargo run -p srt-runtime --example parse_url
//! ```

use srt_runtime::SrtUrl;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = SrtUrl::parse(
        "srt://ingest.example:9000?streamid=%23!::r=live/camera-1,m=publish&latency=200&mode=caller&passphrase=correct-horse-battery",
    )
    .map_err(|rejection| format!("refused: {rejection:?}"))?;
    println!("{url:?}");
    println!(
        "connect to {}:{} as {:?}, stream id {:?}, latency {:?}, encrypted: {}",
        url.host,
        url.port,
        url.mode,
        url.stream_id,
        url.latency,
        url.passphrase.is_some()
    );

    match SrtUrl::parse("srt://ingest.example:9000?latency=fast") {
        Ok(_) => return Err("a non-numeric latency must be refused".into()),
        Err(rejection) => println!("srt://ingest.example:9000?latency=fast refused: {rejection:?}"),
    }
    Ok(())
}