Enum StatusCode

Source
#[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 request
  • 2xx (200-299): Success — The action was successfully received, understood, and accepted
  • 3xx (300-399): Redirection — Further action needs to be taken to complete the request
  • 4xx (400-499): Client Error — The request contains bad syntax or cannot be fulfilled at this server
  • 5xx (500-599): Server Error — The server failed to fulfill an apparently valid request
  • 6xx (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

§

Unauthorized = 401

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

§

TemporarilyUnavailable = 480

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

§

ServiceUnavailable = 503

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

Source

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
Source

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);
Source

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");
Source

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
Source

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
Source

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
Source

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
Source

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
Source

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
Source

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)
Source

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

Source§

fn clone(&self) -> StatusCode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for StatusCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for StatusCode

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<StatusCode, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for StatusCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the status code as a string.

Formats the status code as “ ”, following the standard SIP protocol format.

§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

Source§

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 successful
  • Err(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§

type Err = Error

The associated error which can be returned from parsing.
Source§

impl Hash for StatusCode

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for StatusCode

Source§

fn eq(&self, other: &StatusCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for StatusCode

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for StatusCode

Source§

impl Eq for StatusCode

Source§

impl StructuralPartialEq for StatusCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SipJson for T

Source§

fn to_sip_value(&self) -> Result<SipValue, SipJsonError>

Convert this type to a SipValue. Read more
Source§

fn from_sip_value(value: &SipValue) -> Result<T, SipJsonError>

Create this type from a SipValue. Read more
Source§

impl<T> SipJsonExt for T

Source§

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>

Get a string value at the given path

Source§

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

Source§

fn to_sip_value(&self) -> Result<SipValue, SipJsonError>

Convert to a SipValue. Read more
Source§

fn from_sip_value(value: &SipValue) -> Result<T, SipJsonError>

Convert from a SipValue. Read more
Source§

fn get_path(&self, path: impl AsRef<str>) -> SipValue

Access a value via path notation (e.g., “headers.from.tag”). Read more
Source§

fn path_accessor(&self) -> PathAccessor

Get a PathAccessor for chained access to fields. Read more
Source§

fn query(&self, query_str: impl AsRef<str>) -> Vec<SipValue>

Query for values using a JSONPath-like syntax. Read more
Source§

fn to_json_string(&self) -> Result<String, SipJsonError>

Convert to a JSON string. Read more
Source§

fn to_json_string_pretty(&self) -> Result<String, SipJsonError>

Convert to a pretty-printed JSON string. Read more
Source§

fn from_json_str(json_str: &str) -> Result<T, SipJsonError>

Create from a JSON string. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> SipMessageJson for T
where T: SipJsonExt,