diff options
author | metamuffin <metamuffin@disroot.org> | 2024-07-05 02:27:48 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-07-05 02:27:48 +0200 |
commit | 384ddd782b989218ceb55b7147aa8698425d1464 (patch) | |
tree | 5bfb61317db2e9260129b53b8444f3c79a0bc708 /src/encoding/method.rs | |
parent | 3f80205783bcf6a2ed682f6f21e5b1877d597328 (diff) | |
download | sip-rs-384ddd782b989218ceb55b7147aa8698425d1464.tar sip-rs-384ddd782b989218ceb55b7147aa8698425d1464.tar.bz2 sip-rs-384ddd782b989218ceb55b7147aa8698425d1464.tar.zst |
simpletransaction works
Diffstat (limited to 'src/encoding/method.rs')
-rw-r--r-- | src/encoding/method.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/encoding/method.rs b/src/encoding/method.rs index 5f8110a..73829b0 100644 --- a/src/encoding/method.rs +++ b/src/encoding/method.rs @@ -1,5 +1,7 @@ -use std::fmt::Display; +use anyhow::bail; +use std::{fmt::Display, str::FromStr}; +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum Method { Register, Invite, @@ -21,3 +23,17 @@ impl Display for Method { }) } } +impl FromStr for Method { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result<Self, Self::Err> { + Ok(match s { + "REGISTER" => Method::Register, + "INVITE" => Method::Invite, + "ACK" => Method::Ack, + "OPTION" => Method::Option, + "CANCEL" => Method::Cancel, + "BYE" => Method::Bye, + _ => bail!("unknown method"), + }) + } +} |