#[repr(u16)]pub enum StatusCode {
Show 52 variants
Trying = 100,
Ringing = 180,
CallIsBeingForwarded = 181,
Queued = 182,
SessionProgress = 183,
Ok = 200,
Accepted = 202,
MultipleChoices = 300,
MovedPermanently = 301,
MovedTemporarily = 302,
UseProxy = 305,
AlternativeService = 380,
BadRequest = 400,
Unauthorized = 401,
PaymentRequired = 402,
Forbidden = 403,
NotFound = 404,
MethodNotAllowed = 405,
NotAcceptable = 406,
ProxyAuthenticationRequired = 407,
RequestTimeout = 408,
Gone = 410,
RequestEntityTooLarge = 413,
RequestUriTooLong = 414,
UnsupportedMediaType = 415,
UnsupportedUriScheme = 416,
BadExtension = 420,
ExtensionRequired = 421,
IntervalTooBrief = 423,
TemporarilyUnavailable = 480,
CallOrTransactionDoesNotExist = 481,
LoopDetected = 482,
TooManyHops = 483,
AddressIncomplete = 484,
Ambiguous = 485,
BusyHere = 486,
RequestTerminated = 487,
NotAcceptableHere = 488,
RequestPending = 491,
Undecipherable = 493,
ServerInternalError = 500,
NotImplemented = 501,
BadGateway = 502,
ServiceUnavailable = 503,
ServerTimeout = 504,
VersionNotSupported = 505,
MessageTooLarge = 513,
BusyEverywhere = 600,
Decline = 603,
DoesNotExistAnywhere = 604,
NotAcceptable606 = 606,
Custom(u16),
}
Expand description
SIP status codes as defined in RFC 3261 and extensions
SIP response status codes are used to indicate the outcome of a SIP request. These status codes are organized into six classes:
1xx
(100-199): Provisional — Request received, continuing to process the request2xx
(200-299): Success — The action was successfully received, understood, and accepted3xx
(300-399): Redirection — Further action needs to be taken to complete the request4xx
(400-499): Client Error — The request contains bad syntax or cannot be fulfilled at this server5xx
(500-599): Server Error — The server failed to fulfill an apparently valid request6xx
(600-699): Global Failure — The request cannot be fulfilled at any server
Each status code has a standard reason phrase associated with it, but the numeric value is what determines the meaning of the response.
§Examples
use rvoip_sip_core::prelude::*;
// Check status code classes
let trying = StatusCode::Trying;
assert!(trying.is_provisional()); // 1xx class
let ok = StatusCode::Ok;
assert!(ok.is_success()); // 2xx class
let not_found = StatusCode::NotFound;
assert!(not_found.is_client_error()); // 4xx class
assert!(not_found.is_error()); // Any 4xx, 5xx, or 6xx
// Format status code
assert_eq!(ok.to_string(), "200 OK");
Variants§
Trying = 100
100 Trying
Ringing = 180
180 Ringing
CallIsBeingForwarded = 181
181 Call Is Being Forwarded
Queued = 182
182 Queued
SessionProgress = 183
183 Session Progress
Ok = 200
200 OK
Accepted = 202
202 Accepted
MultipleChoices = 300
300 Multiple Choices
MovedPermanently = 301
301 Moved Permanently
MovedTemporarily = 302
302 Moved Temporarily
UseProxy = 305
305 Use Proxy
AlternativeService = 380
380 Alternative Service
BadRequest = 400
400 Bad Request
401 Unauthorized
PaymentRequired = 402
402 Payment Required
Forbidden = 403
403 Forbidden
NotFound = 404
404 Not Found
MethodNotAllowed = 405
405 Method Not Allowed
NotAcceptable = 406
406 Not Acceptable
ProxyAuthenticationRequired = 407
407 Proxy Authentication Required
RequestTimeout = 408
408 Request Timeout
Gone = 410
410 Gone
RequestEntityTooLarge = 413
413 Request Entity Too Large
RequestUriTooLong = 414
414 Request-URI Too Long
UnsupportedMediaType = 415
415 Unsupported Media Type
UnsupportedUriScheme = 416
416 Unsupported URI Scheme
BadExtension = 420
420 Bad Extension
ExtensionRequired = 421
421 Extension Required
IntervalTooBrief = 423
423 Interval Too Brief
480 Temporarily Unavailable
CallOrTransactionDoesNotExist = 481
481 Call/Transaction Does Not Exist
LoopDetected = 482
482 Loop Detected
TooManyHops = 483
483 Too Many Hops
AddressIncomplete = 484
484 Address Incomplete
Ambiguous = 485
485 Ambiguous
BusyHere = 486
486 Busy Here
RequestTerminated = 487
487 Request Terminated
NotAcceptableHere = 488
488 Not Acceptable Here
RequestPending = 491
491 Request Pending
Undecipherable = 493
493 Undecipherable
ServerInternalError = 500
500 Server Internal Error
NotImplemented = 501
501 Not Implemented
BadGateway = 502
502 Bad Gateway
503 Service Unavailable
ServerTimeout = 504
504 Server Time-out
VersionNotSupported = 505
505 Version Not Supported
MessageTooLarge = 513
513 Message Too Large
BusyEverywhere = 600
600 Busy Everywhere
Decline = 603
603 Decline
DoesNotExistAnywhere = 604
604 Does Not Exist Anywhere
NotAcceptable606 = 606
606 Not Acceptable
Custom(u16)
Custom status code (with value)
Implementations§
Source§impl StatusCode
impl StatusCode
Sourcepub fn from_u16(code: u16) -> Result<StatusCode, Error>
pub fn from_u16(code: u16) -> Result<StatusCode, Error>
Creates a status code from a raw u16 value
This method converts a numeric status code into the corresponding
StatusCode
enum variant. If the numeric code matches a known
status code, the specific variant is returned. Otherwise, if the
code is within the valid range (100-699), a Custom
variant is
returned. If the code is outside this range, an error is returned.
§Parameters
code
: The numeric status code value
§Returns
Ok(StatusCode)
: If the code is valid (100-699)Err(Error::InvalidStatusCode)
: If the code is outside the valid range
§Examples
use rvoip_sip_core::prelude::*;
// Create known status code
let status = StatusCode::from_u16(200).unwrap();
assert_eq!(status, StatusCode::Ok);
// Create custom status code
let status = StatusCode::from_u16(599).unwrap();
match status {
StatusCode::Custom(code) => assert_eq!(code, 599),
_ => panic!("Expected Custom variant"),
}
// Invalid status code
assert!(StatusCode::from_u16(99).is_err()); // Too low
assert!(StatusCode::from_u16(700).is_err()); // Too high
Sourcepub fn as_u16(&self) -> u16
pub fn as_u16(&self) -> u16
Returns the numeric value of this status code
Converts the StatusCode
enum variant back to its underlying numeric value.
§Returns
The numeric value of the status code as a u16
§Examples
use rvoip_sip_core::prelude::*;
assert_eq!(StatusCode::Ok.as_u16(), 200);
assert_eq!(StatusCode::NotFound.as_u16(), 404);
assert_eq!(StatusCode::Custom(499).as_u16(), 499);
Sourcepub fn reason_phrase(&self) -> &'static str
pub fn reason_phrase(&self) -> &'static str
Returns the canonical reason phrase for this status code
Gets the standard reason phrase associated with this status code, as defined in RFC 3261. For custom status codes, “Unknown” is returned.
§Returns
A static string containing the reason phrase
§Examples
use rvoip_sip_core::prelude::*;
assert_eq!(StatusCode::Ok.reason_phrase(), "OK");
assert_eq!(StatusCode::NotFound.reason_phrase(), "Not Found");
assert_eq!(StatusCode::Custom(499).reason_phrase(), "Unknown");
Sourcepub fn is_provisional(&self) -> bool
pub fn is_provisional(&self) -> bool
Returns true if this status code is provisional (1xx)
Checks if the status code is in the provisional (1xx) range. Provisional responses indicate that the request was received and is being processed.
§Returns
true
if the status code is in the range 100-199, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::Trying.is_provisional()); // 100
assert!(StatusCode::Ringing.is_provisional()); // 180
assert!(!StatusCode::Ok.is_provisional()); // 200
assert!(!StatusCode::NotFound.is_provisional()); // 404
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if this status code is success (2xx)
Checks if the status code is in the success (2xx) range. Success responses indicate that the request was successfully received, understood, and accepted.
§Returns
true
if the status code is in the range 200-299, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::Ok.is_success()); // 200
assert!(StatusCode::Accepted.is_success()); // 202
assert!(!StatusCode::Trying.is_success()); // 100
assert!(!StatusCode::MovedTemporarily.is_success()); // 302
Sourcepub fn is_redirection(&self) -> bool
pub fn is_redirection(&self) -> bool
Returns true if this status code is redirection (3xx)
Checks if the status code is in the redirection (3xx) range. Redirection responses indicate that further action needs to be taken in order to complete the request.
§Returns
true
if the status code is in the range 300-399, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::MovedTemporarily.is_redirection()); // 302
assert!(StatusCode::MultipleChoices.is_redirection()); // 300
assert!(!StatusCode::Ok.is_redirection()); // 200
assert!(!StatusCode::BadRequest.is_redirection()); // 400
Sourcepub fn is_client_error(&self) -> bool
pub fn is_client_error(&self) -> bool
Returns true if this status code is client error (4xx)
Checks if the status code is in the client error (4xx) range. Client error responses indicate that the request contains bad syntax or cannot be fulfilled at this server.
§Returns
true
if the status code is in the range 400-499, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::BadRequest.is_client_error()); // 400
assert!(StatusCode::NotFound.is_client_error()); // 404
assert!(StatusCode::BusyHere.is_client_error()); // 486
assert!(!StatusCode::Ok.is_client_error()); // 200
assert!(!StatusCode::ServerInternalError.is_client_error()); // 500
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Returns true if this status code is server error (5xx)
Checks if the status code is in the server error (5xx) range. Server error responses indicate that the server failed to fulfill an apparently valid request.
§Returns
true
if the status code is in the range 500-599, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::ServerInternalError.is_server_error()); // 500
assert!(StatusCode::ServiceUnavailable.is_server_error()); // 503
assert!(!StatusCode::NotFound.is_server_error()); // 404
assert!(!StatusCode::BusyEverywhere.is_server_error()); // 600
Sourcepub fn is_global_failure(&self) -> bool
pub fn is_global_failure(&self) -> bool
Returns true if this status code is global failure (6xx)
Checks if the status code is in the global failure (6xx) range. Global failure responses indicate that the request cannot be fulfilled at any server.
§Returns
true
if the status code is in the range 600-699, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::BusyEverywhere.is_global_failure()); // 600
assert!(StatusCode::Decline.is_global_failure()); // 603
assert!(!StatusCode::ServiceUnavailable.is_global_failure()); // 503
assert!(!StatusCode::NotFound.is_global_failure()); // 404
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Returns true if this status code indicates an error (4xx, 5xx, 6xx)
Checks if the status code is in any of the error ranges: client error (4xx), server error (5xx), or global failure (6xx).
§Returns
true
if the status code is 400 or greater, false
otherwise
§Examples
use rvoip_sip_core::prelude::*;
assert!(StatusCode::NotFound.is_error()); // 404 (4xx)
assert!(StatusCode::ServerInternalError.is_error()); // 500 (5xx)
assert!(StatusCode::BusyEverywhere.is_error()); // 600 (6xx)
assert!(!StatusCode::Ok.is_error()); // 200 (2xx)
assert!(!StatusCode::MovedTemporarily.is_error()); // 302 (3xx)
assert!(!StatusCode::Trying.is_error()); // 100 (1xx)
Sourcepub fn as_reason(&self) -> &'static str
pub fn as_reason(&self) -> &'static str
Get the textual reason phrase for the status code
This is an alias for reason_phrase()
that provides
the standard reason phrase associated with this status code.
§Returns
A static string containing the reason phrase
§Examples
use rvoip_sip_core::prelude::*;
assert_eq!(StatusCode::Ok.as_reason(), "OK");
assert_eq!(StatusCode::NotFound.as_reason(), "Not Found");
assert_eq!(StatusCode::Custom(499).as_reason(), "Custom Status Code");
Trait Implementations§
Source§impl Clone for StatusCode
impl Clone for StatusCode
Source§fn clone(&self) -> StatusCode
fn clone(&self) -> StatusCode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StatusCode
impl Debug for StatusCode
Source§impl<'de> Deserialize<'de> for StatusCode
impl<'de> Deserialize<'de> for StatusCode
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<StatusCode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<StatusCode, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for StatusCode
impl Display for StatusCode
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the status code as a string.
Formats the status code as “
§Examples
use rvoip_sip_core::prelude::*;
use std::fmt::Display;
assert_eq!(StatusCode::Ok.to_string(), "200 OK");
assert_eq!(StatusCode::NotFound.to_string(), "404 Not Found");
assert_eq!(StatusCode::Custom(499).to_string(), "499 Unknown");
Source§impl FromStr for StatusCode
impl FromStr for StatusCode
Source§fn from_str(s: &str) -> Result<StatusCode, Error>
fn from_str(s: &str) -> Result<StatusCode, Error>
Parses a string into a StatusCode.
Parses a string containing a numeric status code into the corresponding StatusCode enum variant. The string should contain just the numeric value (e.g., “200”, “404”).
§Parameters
s
: The string to parse, containing a numeric status code
§Returns
Ok(StatusCode)
: If parsing is successfulErr(Error::InvalidStatusCode)
: If the string cannot be parsed as a valid status code
§Examples
use rvoip_sip_core::prelude::*;
use std::str::FromStr;
// Parse known status codes
let ok = StatusCode::from_str("200").unwrap();
assert_eq!(ok, StatusCode::Ok);
let not_found = StatusCode::from_str("404").unwrap();
assert_eq!(not_found, StatusCode::NotFound);
// Parse custom status code
let custom = StatusCode::from_str("499").unwrap();
match custom {
StatusCode::Custom(code) => assert_eq!(code, 499),
_ => panic!("Expected Custom variant"),
}
// Invalid input
assert!(StatusCode::from_str("abc").is_err());
assert!(StatusCode::from_str("99").is_err());
Source§impl Hash for StatusCode
impl Hash for StatusCode
Source§impl PartialEq for StatusCode
impl PartialEq for StatusCode
Source§impl Serialize for StatusCode
impl Serialize for StatusCode
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 Copy for StatusCode
impl Eq for StatusCode
impl StructuralPartialEq for StatusCode
Auto Trait Implementations§
impl Freeze for StatusCode
impl RefUnwindSafe for StatusCode
impl Send for StatusCode
impl Sync for StatusCode
impl Unpin for StatusCode
impl UnwindSafe for StatusCode
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