pub enum Method {
Show 15 variants
Invite,
Ack,
Bye,
Cancel,
Register,
Options,
Subscribe,
Notify,
Update,
Refer,
Info,
Message,
Prack,
Publish,
Extension(String),
}
Expand description
SIP request methods as defined in RFC 3261 and extensions
This enum represents the standard SIP methods defined in RFC 3261 and common
extensions. It also supports custom extension methods through the Extension
variant.
Each method has specific semantics in the SIP protocol:
- Some methods can establish dialogs (e.g., INVITE, SUBSCRIBE)
- Some methods require responses (most methods except ACK and CANCEL)
- Some methods are defined in the core specification, while others are extensions
§Examples
use rvoip_sip_core::prelude::*;
use std::str::FromStr;
// Core methods
let invite = Method::Invite;
let register = Method::Register;
// Extension methods
let subscribe = Method::Subscribe;
let message = Method::Message;
// Custom extension method
let custom = Method::Extension("CUSTOM".to_string());
// Converting to string
assert_eq!(invite.to_string(), "INVITE");
assert_eq!(custom.to_string(), "CUSTOM");
// Parsing from string
assert_eq!(Method::from_str("BYE").unwrap(), Method::Bye);
Variants§
Invite
INVITE: Initiates a session
Ack
ACK: Confirms a final response to an INVITE
Bye
BYE: Terminates a session
Cancel
CANCEL: Cancels a pending request
Register
REGISTER: Registers contact information
Options
OPTIONS: Queries capabilities
Subscribe
SUBSCRIBE: Requests notification of an event
Notify
NOTIFY: Sends notification of an event
Update
UPDATE: Modifies state of a session without changing dialog state
Refer
REFER: Asks recipient to issue a request
Info
INFO: Sends mid-session information
Message
MESSAGE: Transports instant messages
Prack
PRACK: Provisional acknowledgment
Publish
PUBLISH: Publishes event state
Extension(String)
Custom extension method
Implementations§
Source§impl Method
impl Method
Sourcepub fn creates_dialog(&self) -> bool
pub fn creates_dialog(&self) -> bool
Returns true if the method can establish a dialog
In SIP, only certain methods can create dialogs between user agents. The primary methods that establish dialogs are INVITE and SUBSCRIBE.
§Returns
true
if the method can create a dialog, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
// Methods that create dialogs
assert!(Method::Invite.creates_dialog());
assert!(Method::Subscribe.creates_dialog());
// Methods that don't create dialogs
assert!(!Method::Register.creates_dialog());
assert!(!Method::Message.creates_dialog());
assert!(!Method::Extension("CUSTOM".to_string()).creates_dialog());
Sourcepub fn requires_response(&self) -> bool
pub fn requires_response(&self) -> bool
Returns true if the method requires a response
Most SIP methods require a response, but there are exceptions. ACK and CANCEL are special methods that do not require responses according to the SIP specification.
§Returns
true
if the method requires a response, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
// Methods that require responses
assert!(Method::Invite.requires_response());
assert!(Method::Register.requires_response());
assert!(Method::Subscribe.requires_response());
// Methods that don't require responses
assert!(!Method::Ack.requires_response());
assert!(!Method::Cancel.requires_response());
Sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Returns true if the method is standardized (not an extension)
This method distinguishes between methods defined in the SIP specifications
and custom extension methods. It returns true
for all enum variants except
Method::Extension
.
§Returns
true
if the method is a standard SIP method, false
for custom extensions
§Examples
use rvoip_sip_core::prelude::*;
// Standard methods
assert!(Method::Invite.is_standard());
assert!(Method::Register.is_standard());
assert!(Method::Subscribe.is_standard());
// Custom extension
assert!(!Method::Extension("CUSTOM".to_string()).is_standard());
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Converts the method to its string representation
Returns the canonical string representation of the SIP method.
For standard methods, this is the uppercase name as defined in the
SIP specifications. For extension methods, it’s the string stored
in the Extension
variant.
§Returns
A string slice representing the method
§Examples
use rvoip_sip_core::prelude::*;
assert_eq!(Method::Invite.as_str(), "INVITE");
assert_eq!(Method::Ack.as_str(), "ACK");
assert_eq!(Method::Register.as_str(), "REGISTER");
let custom = Method::Extension("CUSTOM".to_string());
assert_eq!(custom.as_str(), "CUSTOM");
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Method
impl<'de> Deserialize<'de> for Method
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Method, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Method, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for Method
impl Display for Method
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the Method as a string.
This implementation uses as_str()
to convert the method to its
string representation.
§Examples
use rvoip_sip_core::prelude::*;
assert_eq!(Method::Invite.to_string(), "INVITE");
assert_eq!(Method::Register.to_string(), "REGISTER");
// In a formatted string
let method = Method::Invite;
let formatted = format!("SIP method: {}", method);
assert_eq!(formatted, "SIP method: INVITE");
Source§impl FromStr for Method
impl FromStr for Method
Source§fn from_str(s: &str) -> Result<Method, Error>
fn from_str(s: &str) -> Result<Method, Error>
Parses a string into a Method.
This method converts a string to the corresponding Method enum variant.
It recognizes all standard SIP methods defined in RFC 3261 and common
extensions. If the string doesn’t match any standard method but is not empty,
it creates a Method::Extension
variant with the string.
§Parameters
s
: The string to parse
§Returns
A Result containing the parsed Method, or an error if parsing fails
§Errors
Returns Error::InvalidMethod
if the input string is empty.
§Examples
use rvoip_sip_core::prelude::*;
use std::str::FromStr;
// Standard methods
assert_eq!(Method::from_str("INVITE").unwrap(), Method::Invite);
assert_eq!(Method::from_str("BYE").unwrap(), Method::Bye);
// Extension method
let custom = Method::from_str("CUSTOM").unwrap();
assert!(matches!(custom, Method::Extension(s) if s == "CUSTOM"));
// Error case
assert!(Method::from_str("").is_err());
Source§impl Serialize for Method
impl Serialize for Method
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for Method
impl StructuralPartialEq for Method
Auto Trait Implementations§
impl Freeze for Method
impl RefUnwindSafe for Method
impl Send for Method
impl Sync for Method
impl Unpin for Method
impl UnwindSafe for Method
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> SipJson for Twhere
T: Serialize + DeserializeOwned,
impl<T> SipJson for Twhere
T: Serialize + DeserializeOwned,
Source§fn to_sip_value(&self) -> Result<SipValue, SipJsonError>
fn to_sip_value(&self) -> Result<SipValue, SipJsonError>
Source§fn from_sip_value(value: &SipValue) -> Result<T, SipJsonError>
fn from_sip_value(value: &SipValue) -> Result<T, SipJsonError>
Source§impl<T> SipJsonExt for T
impl<T> SipJsonExt for T
Source§fn path(&self, path: impl AsRef<str>) -> Option<SipValue>
fn path(&self, path: impl AsRef<str>) -> Option<SipValue>
Simple path accessor that returns an Option directly
Source§fn path_str(&self, path: impl AsRef<str>) -> Option<String>
fn path_str(&self, path: impl AsRef<str>) -> Option<String>
Get a string value at the given path
Source§fn path_str_or(&self, path: impl AsRef<str>, default: &str) -> String
fn path_str_or(&self, path: impl AsRef<str>, default: &str) -> String
Get a string value at the given path, or return the default value if not found