sip_uri/lib.rs
1//! Zero-dependency SIP/SIPS, tel:, and URN parser.
2//!
3//! Implements RFC 3261 §19/§25 (SIP-URI, SIPS-URI), RFC 3966 (tel-URI),
4//! and RFC 8141 (URN) with hand-written parsing and per-component
5//! percent-encoding.
6//!
7//! # Examples
8//!
9//! ```
10//! use sip_uri::{SipUri, TelUri, UrnUri, Uri};
11//!
12//! // Parse a SIP URI
13//! let uri: SipUri = "sip:alice@example.com;transport=tcp".parse().unwrap();
14//! assert_eq!(uri.user(), Some("alice"));
15//! assert_eq!(uri.param("transport"), Some(&Some("tcp".to_string())));
16//!
17//! // Parse a tel: URI
18//! let tel: TelUri = "tel:+15551234567;cpc=emergency".parse().unwrap();
19//! assert_eq!(tel.number(), "+15551234567");
20//! assert!(tel.is_global());
21//!
22//! // Parse a URN (e.g. NG911 service identifier)
23//! let urn: UrnUri = "urn:service:sos".parse().unwrap();
24//! assert_eq!(urn.nid(), "service");
25//! assert_eq!(urn.nss(), "sos");
26//!
27//! // Dispatch on URI type
28//! let uri: Uri = "urn:service:sos".parse().unwrap();
29//! match uri {
30//! Uri::Sip(sip) => println!("SIP: {sip}"),
31//! Uri::Tel(tel) => println!("Tel: {tel}"),
32//! Uri::Urn(urn) => println!("URN: {urn}"),
33//! Uri::Other(raw) => println!("other: {raw}"),
34//! _ => {}
35//! }
36//! ```
37
38mod error;
39mod host;
40mod name_addr;
41pub(crate) mod params;
42pub(crate) mod parse;
43mod sip_uri;
44mod tel_uri;
45mod uri;
46mod urn_uri;
47
48pub use error::{
49 ParseNameAddrError, ParseSipUriError, ParseTelUriError, ParseUriError, ParseUrnError,
50};
51pub use host::Host;
52#[allow(deprecated)]
53pub use name_addr::NameAddr;
54pub use sip_uri::{Scheme, SipUri};
55pub use tel_uri::TelUri;
56pub use uri::Uri;
57pub use urn_uri::UrnUri;