From cbc111f90b5facc1f2a9dd79ced216279d6260af Mon Sep 17 00:00:00 2001 From: metamuffin Date: Tue, 19 Nov 2024 02:08:52 +0100 Subject: move files + rtp parser --- src/encoding/uri.rs | 55 ----------------------------------------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/encoding/uri.rs (limited to 'src/encoding/uri.rs') diff --git a/src/encoding/uri.rs b/src/encoding/uri.rs deleted file mode 100644 index b1a1282..0000000 --- a/src/encoding/uri.rs +++ /dev/null @@ -1,55 +0,0 @@ -use anyhow::anyhow; -use std::{fmt::Display, str::FromStr}; - -#[derive(Debug, Clone)] -pub struct Uri { - pub protocol: String, - pub localpart: Option, - pub addr: String, - pub params: String, -} - -impl Display for Uri { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let Self { - protocol, - localpart, - addr, - params, - } = self; - write!( - f, - "{protocol}:{}{addr}{}", - if let Some(localpart) = localpart { - format!("{localpart}@") - } else { - "".to_string() - }, - if params.is_empty() { - "".to_string() - } else { - format!(";{params}") - } - )?; - Ok(()) - } -} -impl FromStr for Uri { - type Err = anyhow::Error; - fn from_str(s: &str) -> Result { - let (pr, s) = s.split_once(":").ok_or(anyhow!("protocol sep"))?; - let (lp, s) = s.split_once("@").unwrap_or(("", s)); - let (addr, params) = s.split_once(";").unwrap_or((s, "")); - - Ok(Self { - addr: addr.to_owned(), - localpart: if lp.is_empty() { - None - } else { - Some(lp.to_string()) - }, - params: params.to_string(), - protocol: pr.to_string(), - }) - } -} -- cgit v1.2.3-70-g09d2