Struct SimpleResponseBuilder

Source
pub struct SimpleResponseBuilder { /* private fields */ }
Expand description

§SIP Response Builder

The SimpleResponseBuilder provides a streamlined approach to creating SIP response messages as defined in RFC 3261.

§SIP Response Overview

SIP (Session Initiation Protocol) responses are messages sent by servers to clients in response to client requests. Each response contains a status code indicating the outcome, a reason phrase, and various headers providing additional information.

A typical SIP response looks like:

SIP/2.0 200 OK
Via: SIP/2.0/UDP server10.example.com;branch=z9hG4bK4b43c2ff8.1;received=192.0.2.3
Via: SIP/2.0/UDP client.example.com:5060;branch=z9hG4bK74bf9;received=192.0.2.201
From: Alice <sip:alice@example.com>;tag=9fxced76sl
To: Bob <sip:bob@example.com>;tag=8321234356
Call-ID: 3848276298220188511@client.example.com
CSeq: 1 INVITE
Contact: <sip:bob@client.example.com>
Content-Type: application/sdp
Content-Length: 147

[SDP message body]

§SIP Response Status Codes

SIP defines several categories of status codes:

  • 1xx (Provisional): Request received and being processed (e.g., 100 Trying, 180 Ringing)
  • 2xx (Success): Request was successfully received, understood, and accepted (e.g., 200 OK)
  • 3xx (Redirection): Further action needs to be taken to complete the request (e.g., 302 Moved Temporarily)
  • 4xx (Client Error): Request contains bad syntax or cannot be fulfilled at this server (e.g., 404 Not Found)
  • 5xx (Server Error): Server failed to fulfill an apparently valid request (e.g., 500 Server Internal Error)
  • 6xx (Global Failure): Request cannot be fulfilled at any server (e.g., 603 Decline)

§Key SIP Response Headers

  • Via: Indicates the path taken by the request (copied from request with additional parameters)
  • From: Identifies the logical initiator of the request (copied from request)
  • To: Identifies the logical recipient of the request (copied from request, tag added if needed)
  • Call-ID: Unique identifier for this call or registration (copied from request)
  • CSeq: Sequence number and method for ordering requests (copied from request)
  • Contact: Direct URI at which the responder can be reached (for dialog-establishing responses)
  • Content-Type/Content-Length: Describes the message body, if present

§Dialog Creation and Maintenance

Certain responses help establish and maintain dialogs between SIP user agents:

  • 2xx responses to INVITE: Establish dialogs and must include Contact headers
  • 101-199 responses with to-tag: Establish early dialogs when responding to INVITE
  • Responses within dialogs: Must maintain dialog state with proper tags and CSeq values

§Transaction Model

SIP responses work within transactions to provide reliability:

  • INVITE transaction responses: May include provisional (1xx) responses, followed by final responses
  • Non-INVITE transaction responses: Typically have single final response
  • 2xx responses to INVITE: Establish separate transactions for reliability through ACK

§Benefits of Using SimpleResponseBuilder

The SimpleResponseBuilder provides several advantages:

  • Ergonomic API: Fluent interface with method chaining
  • Default Handling: Sets reasonable defaults for many fields
  • RFC Compliance: Ensures compliance with SIP standards and conventions
  • Header Management: Properly formats and validates SIP headers
  • Status-Specific Builders: Convenience constructors for common responses
  • Type Safety: Leverages Rust’s type system to prevent invalid messages

The examples below demonstrate how to create various types of SIP responses for common scenarios. The SimpleResponseBuilder provides a streamlined approach to creating SIP response messages.

§Examples

§Creating a Basic SIP Response

use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, StatusCode};

let response = SimpleResponseBuilder::new(StatusCode::Ok, Some("OK"))
    .from("Alice", "sip:alice@example.com", Some("1928301774"))
    .to("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .call_id("a84b4c76e66710@pc33.atlanta.com")
    .cseq(1, Method::Invite)
    .via("pc33.atlanta.com", "UDP", Some("z9hG4bK776asdhds"))
    .build();

assert_eq!(response.status_code(), 200);

§Using Convenience Constructors

use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;

// 200 OK response
let ok = SimpleResponseBuilder::ok()
    .from("Alice", "sip:alice@example.com", Some("1928301774"))
    .to("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .call_id("a84b4c76e66710@pc33.atlanta.com")
    .cseq(1, Method::Invite)
    .build();

// 100 Trying response
let trying = SimpleResponseBuilder::trying()
    .from("Alice", "sip:alice@example.com", Some("1928301774"))
    .to("Bob", "sip:bob@example.com", None)
    .call_id("a84b4c76e66710@pc33.atlanta.com")
    .cseq(1, Method::Invite)
    .build();

// 180 Ringing response
let ringing = SimpleResponseBuilder::ringing()
    .from("Alice", "sip:alice@example.com", Some("1928301774"))
    .to("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .call_id("a84b4c76e66710@pc33.atlanta.com")
    .cseq(1, Method::Invite)
    .build();

§Adding SDP Content

use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, StatusCode};
use rvoip_sip_core::sdp::SdpBuilder;
use rvoip_sip_core::sdp::attributes::MediaDirection;

// Create an SDP body using the SdpBuilder pattern
let sdp_body = SdpBuilder::new("Session")
    .origin("bob", "2890844527", "2890844527", "IN", "IP4", "127.0.0.1")
    .connection("IN", "IP4", "127.0.0.1")
    .time("0", "0")
    .media_audio(49172, "RTP/AVP")
        .formats(&["0"])
        .rtpmap("0", "PCMU/8000")
        .done()
    .build()
    .expect("Valid SDP");

let response = SimpleResponseBuilder::ok()
    .from("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .to("Alice", "sip:alice@example.com", Some("1928301774"))
    .call_id("a84b4c76e66710@pc33.atlanta.com")
    .cseq(1, Method::Invite)
    .content_type("application/sdp")
    .body(sdp_body.to_string())
    .build();

§Working with Contact Headers

use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, StatusCode};

let response = SimpleResponseBuilder::ok()
    .from("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .to("Alice", "sip:alice@example.com", Some("1928301774"))
    .call_id("a84b4c76e66710@pc33.atlanta.com")
    .cseq(1, Method::Invite)
    .contact("sip:bob@192.168.1.2:5060", Some("Bob"))
    .build();

§Creating Responses from Existing Ones

use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Response, StatusCode};

// Create or get a response from somewhere
let response = Response::new(StatusCode::Ok);

// Create a builder from the existing response
let modified_response = SimpleResponseBuilder::from_response(response)
    .from("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .to("Alice", "sip:alice@example.com", Some("1928301774"))
    .build();

Implementations§

Source§

impl SimpleResponseBuilder

Source

pub fn new(status: StatusCode, reason: Option<&str>) -> Self

Create a new SimpleResponseBuilder with the specified status code and optional reason phrase

This is the main entry point for creating a SIP response builder. Status codes are defined in RFC 3261 Section 21.

§Parameters
  • status: The SIP status code (e.g., StatusCode::Ok (200), StatusCode::NotFound (404))
  • reason: Optional custom reason phrase (if None, the default for the status code will be used)
§Returns

A new SimpleResponseBuilder

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

// Create with default reason phrase
let ok_builder = SimpleResponseBuilder::new(StatusCode::Ok, None);

// Create with custom reason phrase
let not_found_builder = SimpleResponseBuilder::new(StatusCode::NotFound, Some("User Not Available"));
Source

pub fn response_from_request( request: &Request, status: StatusCode, reason: Option<&str>, ) -> Self

Create a response for a request with automatic header copying according to SIP standards

This method creates a response based on an existing request, automatically copying the headers that should be included in responses according to SIP standards.

§Parameters
  • request: The SIP request for which to create a response
  • status: The status code for the response
  • reason: Optional custom reason phrase (if None, the default will be used)
§Returns

A SimpleResponseBuilder with appropriate headers copied from the request

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{StatusCode, Request, Method, Version};
use rvoip_sip_core::Uri;
use std::str::FromStr;

// In a real example, you'd receive an actual request from a client
// Here we just create a minimal request for demonstration
let uri = Uri::from_str("sip:bob@example.com").unwrap();
let request = Request::new(Method::Invite, uri);

// Create a 200 OK response with all appropriate headers copied
let ok_response = SimpleResponseBuilder::response_from_request(&request, StatusCode::Ok, None)
    .contact("sip:bob@192.168.1.2:5060", None)
    .build();
Source

pub fn dialog_response( request: &Request, status: StatusCode, reason: Option<&str>, ) -> Self

Create a standard dialog-establishing response

This is a convenience method that creates a response with the standard set of headers needed for dialog establishment, including adding a local tag to the To header if not present.

§Parameters
  • request: The SIP request for which to create a response
  • status: The status code for the response
  • reason: Optional custom reason phrase (if None, the default will be used)
§Returns

A SimpleResponseBuilder with standard dialog headers

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{StatusCode, Request, Method, Version};
use rvoip_sip_core::Uri;
use std::str::FromStr;
use rvoip_sip_core::types::from::From as FromType;
use rvoip_sip_core::types::to::To as ToType;
use rvoip_sip_core::types::call_id::CallId;

// In a real example, you'd receive an actual request from a client
// Here we just create a minimal request for demonstration
let uri = Uri::from_str("sip:bob@example.com").unwrap();
let request = Request::new(Method::Invite, uri);

// Create a 200 OK response for dialog establishment
let ok_response = SimpleResponseBuilder::dialog_response(&request, StatusCode::Ok, None)
    .contact("sip:bob@192.168.1.2:5060", None)
    .build();
Source

pub fn error_response( request: &Request, status: StatusCode, reason: Option<&str>, ) -> Self

Create a minimal error response

This is a convenience method that creates a response with the minimal set of headers needed for error responses.

§Parameters
  • request: The SIP request for which to create a response
  • status: The status code for the response
  • reason: Optional custom reason phrase (if None, the default will be used)
§Returns

A SimpleResponseBuilder with minimal headers for error responses

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{StatusCode, Request, Method, Version};
use rvoip_sip_core::Uri;
use std::str::FromStr;
use rvoip_sip_core::types::from::From as FromType;
use rvoip_sip_core::types::to::To as ToType;
use rvoip_sip_core::types::call_id::CallId;

// In a real example, you'd receive an actual request from a client
// Here we just create a minimal request for demonstration
let uri = Uri::from_str("sip:bob@example.com").unwrap();
let request = Request::new(Method::Invite, uri);

// Create a 404 Not Found error response
let not_found = SimpleResponseBuilder::error_response(&request, StatusCode::NotFound, None)
    .build();
Source

pub fn from_response(response: Response) -> Self

Create from an existing Response object

This allows you to modify an existing response by using the builder pattern.

§Parameters
  • response: An existing SIP Response object
§Returns

A SimpleResponseBuilder initialized with the provided response

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Response, StatusCode};

// Create a response or get it from somewhere
let response = Response::new(StatusCode::Ok);

// Create a builder from the existing response
let builder = SimpleResponseBuilder::from_response(response);
Source

pub fn ok() -> Self

Create a 200 OK response

This is a convenience constructor for creating a 200 OK response as specified in RFC 3261 Section 21.2.1. 200 OK responses indicate the request was successful.

§Returns

A SimpleResponseBuilder with a 200 OK status

§Examples
§Basic 200 OK Response
use rvoip_sip_core::builder::SimpleResponseBuilder;

let builder = SimpleResponseBuilder::ok();
§Complete 200 OK Response to an INVITE
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;
 
// Create a 200 OK response accepting an INVITE request
let ok_response = SimpleResponseBuilder::ok()
    // Copy headers from the original request
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", Some("b5qt9xl3"))  // Add local tag
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)  // Same CSeq and method as request
    // Copy Via headers from request (in same order)
    .via("proxy.example.com:5060", "UDP", Some("z9hG4bK776asdhds"))
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Contact header is required in 2xx responses to INVITE
    .contact("sip:bob@192.168.1.2:5060", Some("Bob"))
    .build();
§200 OK Response with SDP Answer
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;
use rvoip_sip_core::sdp::SdpBuilder;
use rvoip_sip_core::sdp::attributes::MediaDirection;
 
// Create an SDP answer using the SdpBuilder pattern
let sdp_answer = SdpBuilder::new("SIP Call")
    .origin("bob", "2890844527", "2890844527", "IN", "IP4", "192.168.1.2")
    .connection("IN", "IP4", "192.168.1.2")
    .time("0", "0")
    .media_audio(49172, "RTP/AVP")
        .formats(&["0", "8"])
        .rtpmap("0", "PCMU/8000")
        .rtpmap("8", "PCMA/8000")
        .direction(MediaDirection::SendRecv)
        .done()
    .build()
    .expect("Valid SDP");

// Create a 200 OK response with SDP answer to INVITE
let ok_with_sdp = SimpleResponseBuilder::ok()
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", Some("b5qt9xl3"))
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    .via("proxy.example.com:5060", "UDP", Some("z9hG4bK776asdhds"))
    .contact("sip:bob@192.168.1.2:5060", None)
    // Add SDP body with selected codecs
    .content_type("application/sdp")
    .body(sdp_answer.to_string())
    .build();
Source

pub fn trying() -> Self

Create a 100 Trying response

This is a convenience constructor for creating a 100 Trying response as specified in RFC 3261 Section 21.1.1. 100 Trying responses indicate the request has been received and the server is working on it.

§Returns

A SimpleResponseBuilder with a 100 Trying status

§Examples
§Basic 100 Trying Response
use rvoip_sip_core::builder::SimpleResponseBuilder;

let builder = SimpleResponseBuilder::trying();
§Complete 100 Trying Response to an INVITE
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;

// Create a 100 Trying response to acknowledge receipt of an INVITE
// This is typically sent by a proxy or UAS while processing the request
let trying_response = SimpleResponseBuilder::trying()
    // Copy headers from the original request (no tags added for provisional responses)
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", None)  // No To tag in initial provisional response
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    // Copy all Via headers from request (in same order)
    .via("proxy.example.com:5060", "UDP", Some("z9hG4bK776asdhds"))
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    .build();
§100 Trying with Server Information
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, TypedHeader};

// Create a 100 Trying response with Server header
let trying_with_server = SimpleResponseBuilder::trying()
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", None)
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    .via("proxy.example.com:5060", "UDP", Some("z9hG4bK776asdhds"))
    // Add Server header to identify the server software
    .header(TypedHeader::Server(vec![
        "RVoIP-Proxy/1.0".to_string(),
        "(Linux)".to_string()
    ]))
    .build();
Source

pub fn ringing() -> Self

Create a 180 Ringing response

This is a convenience constructor for creating a 180 Ringing response as specified in RFC 3261 Section 21.1.2. 180 Ringing responses indicate the user agent has located the callee and is alerting them.

§Returns

A SimpleResponseBuilder with a 180 Ringing status

§Examples
§Basic 180 Ringing Response
use rvoip_sip_core::builder::SimpleResponseBuilder;

let builder = SimpleResponseBuilder::ringing();
§Complete 180 Ringing Response for an INVITE
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;

// Create a 180 Ringing response to indicate the destination is being alerted
let ringing_response = SimpleResponseBuilder::ringing()
    // Copy headers from the original request
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", Some("b5qt9xl3"))  // Add To tag to establish early dialog
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    // Copy Via headers from request (in same order)
    .via("proxy.example.com:5060", "UDP", Some("z9hG4bK776asdhds"))
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Contact header in provisional responses helps with early media
    .contact("sip:bob@192.168.1.2:5060", None)
    .build();
§180 Ringing with Early Media (SDP)
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;
use rvoip_sip_core::sdp::SdpBuilder;
use rvoip_sip_core::sdp::attributes::MediaDirection;

// Create an SDP for early media (ringback tone) using SdpBuilder pattern
let early_media_sdp = SdpBuilder::new("Ringback Tone")
    .origin("bob", "2890844527", "2890844527", "IN", "IP4", "192.168.1.2")
    .connection("IN", "IP4", "192.168.1.2")
    .time("0", "0")
    .media_audio(49172, "RTP/AVP")
        .formats(&["0"])
        .rtpmap("0", "PCMU/8000")
        .direction(MediaDirection::SendOnly)  // SendOnly for ringback tone
        .done()
    .build()
    .expect("Valid SDP");

// Create a 180 Ringing response with early media (ringback tone)
let ringing_with_media = SimpleResponseBuilder::ringing()
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", Some("b5qt9xl3"))
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    .via("proxy.example.com:5060", "UDP", Some("z9hG4bK776asdhds"))
    .contact("sip:bob@192.168.1.2:5060", None)
    // Add SDP body for early media (ringback tone)
    .content_type("application/sdp")
    .body(early_media_sdp.to_string())
    .build();
Source

pub fn bad_request() -> Self

Create a 400 Bad Request response

This is a convenience constructor for creating a 400 Bad Request response as specified in RFC 3261 Section 21.4.1. 400 Bad Request responses indicate the server couldn’t understand the request due to malformed syntax.

§Returns

A SimpleResponseBuilder with a 400 Bad Request status

§Examples
§Basic 400 Bad Request Response
use rvoip_sip_core::builder::SimpleResponseBuilder;

let builder = SimpleResponseBuilder::bad_request();
§Complete 400 Bad Request Response with Reason
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, TypedHeader, Warning};
use rvoip_sip_core::types::uri::Uri;
use std::str::FromStr;

// Create warning with proper Uri (not string)
let agent_uri = Uri::from_str("sip:proxy.example.com").unwrap();
let warning = Warning::new(399, agent_uri, "Malformed Contact header");

// Create a 400 Bad Request response for a malformed request
let bad_request_response = SimpleResponseBuilder::bad_request()
    // Include original headers when possible
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", None)  // No To tag for error responses
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    // Copy topmost Via header only for error responses
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Add a Warning header with more information about the error
    .header(TypedHeader::Warning(vec![warning]))
    .build();
§400 Bad Request with Detailed Error Message
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, TypedHeader, Warning};

// Create an explanation of the syntax error in plain text
let error_body = 
    "The request contained a malformed header:\r\n\
    Contact: <sip:bob@example.com missing-bracket\r\n\
    \r\n\
    The correct format should be:\r\n\
    Contact: <sip:bob@example.com>";

// Create a 400 Bad Request with a text explanation
let detailed_response = SimpleResponseBuilder::bad_request()
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", None)
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Add a detailed explanation in the body
    .content_type("text/plain")
    .body(error_body)
    .build();
Source

pub fn not_found() -> Self

Create a 404 Not Found response

This is a convenience constructor for creating a 404 Not Found response as specified in RFC 3261 Section 21.4.4. 404 Not Found responses indicate the server has definitive information that the user does not exist at the domain specified in the Request-URI.

§Returns

A SimpleResponseBuilder with a 404 Not Found status

§Examples
§Basic 404 Not Found Response
use rvoip_sip_core::builder::SimpleResponseBuilder;

let builder = SimpleResponseBuilder::not_found();
§Complete 404 Not Found Response
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;

// Create a 404 Not Found response to an INVITE
let not_found_response = SimpleResponseBuilder::not_found()
    // Include original headers from the request
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Unknown", "sip:unknown@example.com", None)  // No To tag for error responses
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    // Only include the top Via header in error responses
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    .build();
§404 Not Found with Alternative Destination
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, TypedHeader};

// Create a 404 Not Found with alternative contact information
let alternative_response = SimpleResponseBuilder::not_found()
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@old-domain.example.com", None)
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Add a Contact header with alternative location
    .contact("sip:bob@new-domain.example.com", Some("Bob"))
    // Note: Reason header commented out until implemented
    /*
    // Add a Reason header explaining the change
    .header(TypedHeader::Reason(
        Reason::new("SIP", 301, Some("User moved permanently"))
    ))
    */
    .build();
Source

pub fn server_error() -> Self

Create a 500 Server Error response

This is a convenience constructor for creating a 500 Server Internal Error response as specified in RFC 3261 Section 21.5.1. 500 Server Internal Error responses indicate the server encountered an unexpected condition that prevented it from fulfilling the request.

§Returns

A SimpleResponseBuilder with a 500 Server Internal Error status

§Examples
§Basic 500 Server Error Response
use rvoip_sip_core::builder::SimpleResponseBuilder;

let builder = SimpleResponseBuilder::server_error();
§Complete 500 Server Error Response
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::Method;
 
// Create a 500 Server Error response for an INVITE
let server_error_response = SimpleResponseBuilder::server_error()
    // Include original headers from the request
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", None)  // No To tag for error responses
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    // Only include the top Via header in error responses
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Note: RetryAfter header commented out until implemented
    /*
    // Include a Retry-After header suggesting when to retry
    .header(TypedHeader::RetryAfter(RetryAfter::new(300)))  // Retry after 5 minutes
    */
    .build();
§500 Server Error with Detailed Warning
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{Method, TypedHeader, Warning};
use rvoip_sip_core::types::uri::Uri;
use std::str::FromStr;

// Create warning URIs
let agent_uri = Uri::from_str("sip:sip.example.com").unwrap();

// Create a 500 Server Error with detailed warning information
let detailed_error = SimpleResponseBuilder::server_error()
    .from("Alice", "sip:alice@example.com", Some("a73kszlfl"))
    .to("Bob", "sip:bob@example.com", None)
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@192.168.1.2")
    .cseq(1, Method::Invite)
    .via("alice-pc.example.com:5060", "UDP", Some("z9hG4bK123abcde"))
    // Add informative headers
    .header(TypedHeader::Warning(vec![
        Warning::new(399, agent_uri.clone(), "Database connection timeout"),
        Warning::new(399, agent_uri, "Server is under heavy load")
    ]))
    // Note: RetryAfter and Server headers commented out until implemented
    /*
    .header(TypedHeader::RetryAfter(RetryAfter::new(120)))  // Retry after 2 minutes
    .header(TypedHeader::Server(vec![
        "SIP-Core/1.0".to_string(),
        "(Maintenance Mode)".to_string()
    ]))
    */
    .build();
Source

pub fn from(self, display_name: &str, uri: &str, tag: Option<&str>) -> Self

Add a From header with optional tag parameter

Creates and adds a From header as specified in RFC 3261 Section 20.20. In responses, the From header is copied from the request.

§Parameters
  • display_name: The display name for the From header (e.g., “Alice”)
  • uri: The URI for the From header (e.g., “sip:alice@example.com”)
  • tag: Optional tag parameter (should be the same as in the request)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .from("Alice", "sip:alice@example.com", Some("1928301774"));
Source

pub fn to(self, display_name: &str, uri: &str, tag: Option<&str>) -> Self

Add a To header with optional tag parameter

Creates and adds a To header as specified in RFC 3261 Section 20.39. In responses, the To header is copied from the request and a tag is added if it didn’t already have one.

§Parameters
  • display_name: The display name for the To header (e.g., “Bob”)
  • uri: The URI for the To header (e.g., “sip:bob@example.com”)
  • tag: Optional tag parameter (should be added by UAS for dialogs)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .to("Bob", "sip:bob@example.com", Some("a6c85cf"));
Source

pub fn call_id(self, call_id: &str) -> Self

Add a Call-ID header

Creates and adds a Call-ID header as specified in RFC 3261 Section 20.8. In responses, the Call-ID is copied from the request.

§Parameters
  • call_id: The Call-ID value (e.g., “f81d4fae-7dec-11d0-a765-00a0c91e6bf6@example.com”)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .call_id("f81d4fae-7dec-11d0-a765-00a0c91e6bf6@host.example.com");
Source

pub fn cseq(self, seq: u32, method: Method) -> Self

Add a CSeq header for responses (requires method)

Creates and adds a CSeq header as specified in RFC 3261 Section 20.16. In responses, the CSeq is copied from the request, including both the sequence number and method.

§Parameters
  • seq: The sequence number (e.g., 1, 2, 3)
  • method: The method in the CSeq header (e.g., Method::Invite)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{StatusCode, Method};

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .cseq(1, Method::Invite);
Source

pub fn via(self, host: &str, transport: &str, branch: Option<&str>) -> Self

Add a Via header with optional branch parameter

Creates and adds a Via header as specified in RFC 3261 Section 20.42. In responses, the Via headers are copied from the request in the same order.

§Parameters
  • host: The host or IP address (e.g., “192.168.1.1” or “example.com:5060”)
  • transport: The transport protocol (UDP, TCP, TLS, etc.)
  • branch: Optional branch parameter (should be the same as in the request)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .via("192.168.1.1:5060", "UDP", Some("z9hG4bK776asdhds"));
Source

pub fn contact(self, uri: &str, display_name: Option<&str>) -> Self

Add a Contact header

Creates and adds a Contact header as specified in RFC 3261 Section 20.10. In responses, the Contact header provides a URI for subsequent requests in the dialog.

§Parameters
  • uri: The contact URI as a string (e.g., “sip:bob@192.168.1.2:5060”)
  • display_name: Optional display name (e.g., “Bob”)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .contact("sip:bob@192.168.1.2:5060", Some("Bob"));
Source

pub fn content_type(self, content_type: &str) -> Self

Add a Content-Type header

Creates and adds a Content-Type header as specified in RFC 3261 Section 20.15. The Content-Type header indicates the media type of the message body.

§Parameters
  • content_type: The content type (e.g., “application/sdp”)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .content_type("application/sdp");
Source

pub fn header(self, header: TypedHeader) -> Self

Add a generic header

Allows adding any supported SIP header type using the TypedHeader enum. This is useful for headers that don’t have a dedicated method in the builder.

§Parameters
  • header: The typed header to add
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{StatusCode, TypedHeader};
use rvoip_sip_core::types::server::ServerInfo;

// Create a vector of server product tokens
let server_products = vec!["SIPCore/2.1".to_string(), "(High Performance Edition)".to_string()];

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .header(TypedHeader::Server(server_products));
Source

pub fn body(self, body: impl Into<Bytes>) -> Self

Add body content and update Content-Length

Adds a message body to the response and automatically sets the Content-Length header as specified in RFC 3261 Section 20.14.

§Parameters
  • body: The body content (e.g., SDP for session description)
§Returns

Self for method chaining

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::StatusCode;
use rvoip_sip_core::sdp::SdpBuilder;
use rvoip_sip_core::sdp::attributes::MediaDirection;

// Create an SDP body using the SdpBuilder pattern
let sdp_body = SdpBuilder::new("Session")
    .origin("bob", "2890844527", "2890844527", "IN", "IP4", "127.0.0.1")
    .connection("IN", "IP4", "127.0.0.1")
    .time("0", "0")
    .media_audio(49172, "RTP/AVP")
        .formats(&["0"])
        .rtpmap("0", "PCMU/8000")
        .done()
    .build()
    .expect("Valid SDP");

let builder = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .content_type("application/sdp")
    .body(sdp_body.to_string());
Source

pub fn build(self) -> Response

Build the final Response

Finalizes the response construction and returns the complete SIP response.

§Returns

The constructed Response

§Example
use rvoip_sip_core::builder::SimpleResponseBuilder;
use rvoip_sip_core::types::{StatusCode, Method};

let response = SimpleResponseBuilder::new(StatusCode::Ok, None)
    .from("Alice", "sip:alice@example.com", Some("1928301774"))
    .to("Bob", "sip:bob@example.com", Some("a6c85cf"))
    .call_id("a84b4c76e66710")
    .cseq(1, Method::Invite)
    .via("example.com", "UDP", Some("z9hG4bK776asdhds"))
    .build();

Trait Implementations§

Source§

impl CSeqBuilderExt for SimpleResponseBuilder

Source§

fn cseq(self, seq: u32) -> Self

Add a CSeq header with specified sequence number Read more
Source§

fn cseq_with_method(self, seq: u32, method: Method) -> Self

Add a CSeq header with specified sequence number and method Read more
Source§

impl CallIdBuilderExt for SimpleResponseBuilder

Source§

fn call_id(self, call_id: &str) -> Self

Add a Call-ID header with a specific value Read more
Source§

fn random_call_id(self) -> Self

Add a randomly generated Call-ID header Read more
Source§

fn random_call_id_with_host(self, host: &str) -> Self

Add a randomly generated Call-ID header with a host part Read more
Source§

impl CallInfoBuilderExt for SimpleResponseBuilder

Source§

fn call_info_uri(self, uri: &str, purpose: Option<&str>) -> Self

Add a Call-Info header using a URI string Read more
Source§

fn call_info_value(self, value: CallInfoValue) -> Self

Add a Call-Info header with a pre-constructed CallInfoValue Read more
Source§

fn call_info_values(self, values: Vec<CallInfoValue>) -> Self

Add a Call-Info header with multiple values Read more
Source§

impl ContactBuilderExt for SimpleResponseBuilder

Source§

fn contact(self, uri: &str, display_name: Option<&str>) -> Self

Add a Contact header. Read more
Source§

impl ContentBuilderExt for SimpleResponseBuilder

Implementation for new SimpleResponseBuilder

Source§

fn sdp_body(self, sdp: &SdpSession) -> Self

Add an SDP session as the message body Read more
Source§

impl ContentLengthBuilderExt for SimpleResponseBuilder

Source§

fn content_length(self, length: u32) -> Self

Add a Content-Length header with a specific byte length value Read more
Source§

fn no_content(self) -> Self

Add a Content-Length header with value 0 Read more
Source§

impl ContentTypeBuilderExt for SimpleResponseBuilder

Source§

fn content_type_sdp(self) -> Self

Add a Content-Type header specifying ‘application/sdp’ Read more
Source§

fn content_type_text(self) -> Self

Add a Content-Type header specifying ‘text/plain’ Read more
Source§

fn content_type_xml(self) -> Self

Add a Content-Type header specifying ‘application/xml’ Read more
Source§

fn content_type_json(self) -> Self

Add a Content-Type header specifying ‘application/json’ Read more
Source§

fn content_type_sipfrag(self) -> Self

Add a Content-Type header specifying ‘message/sipfrag’ Read more
Source§

fn content_type_custom(self, media_type: &str, media_subtype: &str) -> Self

Add a Content-Type header with a custom media type Read more
Source§

fn content_type(self, content_type: &str) -> Self

Add a Content-Type header Read more
Source§

impl FromBuilderExt for SimpleResponseBuilder

Source§

fn from(self, display_name: &str, uri: &str, tag: Option<&str>) -> Self

Add a From header with an optional tag parameter. Read more
Source§

impl HeaderSetter for SimpleResponseBuilder

Source§

fn set_header<H: TypedHeaderTrait + 'static>(self, header: H) -> Self

Set a header on the builder
Source§

impl MaxForwardsBuilderExt for SimpleResponseBuilder

Source§

fn max_forwards(self, value: u32) -> Self

Add a Max-Forwards header Read more
Source§

impl MimeVersionBuilderExt for SimpleResponseBuilder

Source§

fn mime_version_1_0(self) -> Self

Add a MIME-Version header with version 1.0 Read more
Source§

fn mime_version(self, major: u32, minor: u32) -> Self

Add a MIME-Version header with custom version numbers Read more
Source§

impl RouteBuilderExt for ResponseBuilder

Source§

fn route_uri(self, uri: Uri) -> Self

Add a Route header with a URI Read more
Source§

fn route_address(self, address: Address) -> Self

Add a Route header with an Address Read more
Source§

fn route_entry(self, entry: RouteEntry) -> Self

Add a Route header with a raw RouteEntry Read more
Source§

fn route_entries(self, entries: Vec<RouteEntry>) -> Self

Add a Route header with multiple entries Read more
Source§

impl ToBuilderExt for SimpleResponseBuilder

Source§

fn to(self, display_name: &str, uri: &str, tag: Option<&str>) -> Self

Add a To header with an optional tag parameter. Read more
Source§

impl ViaBuilderExt for SimpleResponseBuilder

Source§

fn via(self, host: &str, transport: &str, branch: Option<&str>) -> Self

Add a Via header with optional branch parameter Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AcceptEncodingExt for T
where T: HeaderSetter,

Source§

fn accept_encoding(self, encoding: &str, q: Option<f32>) -> T

Add an Accept-Encoding header with a single encoding Read more
Source§

fn accept_encodings(self, encodings: Vec<(&str, Option<f32>)>) -> T

Add an Accept-Encoding header with multiple encodings Read more
Source§

impl<T> AcceptExt for T
where T: HeaderSetter,

Source§

fn accept(self, media_type: &str, q: Option<f32>) -> T

Add an Accept header with a single media type Read more
Source§

fn accepts(self, media_types: Vec<(&str, Option<f32>)>) -> T

Add an Accept header with multiple media types Read more
Source§

impl<T> AcceptLanguageExt for T
where T: HeaderSetter,

Source§

fn accept_language(self, language: &str, q: Option<f32>) -> T

Add an Accept-Language header with a single language Read more
Source§

fn accept_languages(self, languages: Vec<(&str, Option<f32>)>) -> T

Add an Accept-Language header with multiple languages Read more
Source§

impl<T> AlertInfoBuilderExt for T
where T: HeaderSetter,

Source§

fn alert_info(self, uri: Uri) -> T

Add an Alert-Info header with the specified URI Read more
Source§

fn alert_info_uri(self, uri_str: &str) -> T

Add an Alert-Info header with a URI parsed from a string Read more
Source§

fn alert_info_with_param( self, uri: Uri, param_name: &str, param_value: &str, ) -> T

Add an Alert-Info header with a URI and a single parameter Read more
Source§

fn alert_info_uri_with_param( self, uri_str: &str, param_name: &str, param_value: &str, ) -> T

Add an Alert-Info header with a URI string and a single parameter Read more
Source§

fn alert_info_with_params(self, uri: Uri, params: Vec<(&str, &str)>) -> T

Add an Alert-Info header with a URI and multiple parameters Read more
Source§

impl<T> AllowBuilderExt for T
where T: HeaderSetter,

Source§

fn allow_method(self, method: Method) -> T

Add an Allow header with a single method Read more
Source§

fn allow_methods(self, methods: Vec<Method>) -> T

Add an Allow header with multiple methods Read more
Source§

fn allow_standard_methods(self) -> T

Add an Allow header with standard methods for UA (User Agent) operations Read more
Source§

fn allow_all_methods(self) -> T

Add an Allow header with all common SIP methods Read more
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> AuthenticationInfoExt for T
where T: HeaderSetter,

Source§

fn authentication_info( self, nextnonce: Option<&str>, qop: Option<&str>, rspauth: Option<&str>, cnonce: Option<&str>, nc: Option<&str>, ) -> T

Add an Authentication-Info header to the response Read more
Source§

impl<T> AuthorizationExt for T
where T: HeaderSetter,

Source§

fn authorization_digest( self, username: &str, realm: &str, nonce: &str, response: &str, cnonce: Option<&str>, qop: Option<&str>, nc: Option<&str>, method: Option<&str>, uri: Option<&str>, algorithm: Option<&str>, opaque: Option<&str>, ) -> T

Add a Digest Authorization header to the request Read more
Source§

fn authorization_basic(self, username: &str, password: &str) -> T

Add a Basic Authorization header to the request 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> ContentDispositionExt for T
where T: HeaderSetter,

Source§

fn content_disposition_session(self, handling: &str) -> T

Add a Content-Disposition header with session disposition type Read more
Source§

fn content_disposition_render(self, handling: &str) -> T

Add a Content-Disposition header with render disposition type Read more
Source§

fn content_disposition_icon(self, size: &str) -> T

Add a Content-Disposition header with icon disposition type Read more
Source§

fn content_disposition_alert(self, handling: Option<&str>) -> T

Add a Content-Disposition header with alert disposition type Read more
Source§

fn content_disposition( self, disposition_type: &str, params: HashMap<String, String>, ) -> T

Add a Content-Disposition header with a custom disposition type Read more
Source§

impl<T> ContentEncodingExt for T
where T: HeaderSetter,

Source§

fn content_encoding(self, encoding: &str) -> T

Add a Content-Encoding header with a single encoding Read more
Source§

fn content_encodings<S>(self, encodings: &[S]) -> T
where S: AsRef<str>,

Add a Content-Encoding header with multiple encodings Read more
Source§

impl<T> ContentLanguageExt for T
where T: HeaderSetter,

Source§

fn content_language(self, language: &str) -> T

Add a Content-Language header with a single language Read more
Source§

fn content_languages<S>(self, languages: &[S]) -> T
where S: AsRef<str>,

Add a Content-Language header with multiple languages Read more
Source§

impl<T> ErrorInfoBuilderExt for T
where T: HeaderSetter,

Source§

fn error_info_uri(self, uri: &str) -> T

Add an Error-Info header with a URI Read more
Source§

fn error_info_uri_with_param( self, uri: &str, param_name: &str, param_value: &str, ) -> T

Add an Error-Info header with a URI and a parameter Read more
Source§

fn error_info_uri_with_params(self, uri: &str, params: Vec<(&str, &str)>) -> T

Add an Error-Info header with a URI and multiple parameters Read more
Source§

fn error_info_uri_with_comment(self, uri: &str, comment: &str) -> T

Add an Error-Info header with a URI and a comment Read more
Source§

fn error_info_uris(self, uris: Vec<&str>) -> T

Add multiple Error-Info headers to a response Read more
Source§

impl<T> EventBuilderExt for T
where T: HeaderSetter,

Source§

fn event(self, event_data: Event) -> T

Sets the Event header using a pre-constructed Event object. Read more
Source§

fn event_type(self, event_type: EventType) -> T

Sets the Event header with a specific event type and no id or other parameters. Read more
Source§

fn event_id(self, event_type: EventType, id: impl Into<String>) -> T

Sets the Event header with an event type and an id parameter. Read more
Source§

fn event_full( self, event_type: EventType, id: Option<impl Into<String>>, params_vec: Vec<(impl Into<String>, Option<impl Into<String>>)>, ) -> T

Sets the Event header with an event type, an optional id, and generic parameters. Read more
Source§

fn event_presence(self, id: Option<impl Into<String>>) -> T

Convenience method to set a “presence” event. Read more
Source§

fn event_conference(self, id: Option<impl Into<String>>) -> T

Convenience method to set a “conference” event (as a package). Read more
Source§

fn event_dialog(self, id: Option<impl Into<String>>) -> T

Convenience method to set a “dialog” event. Read more
Source§

fn event_message_summary(self, id: Option<impl Into<String>>) -> T

Convenience method to set a “message-summary” event. Read more
Source§

impl<T> ExpiresBuilderExt for T
where T: HeaderSetter,

Source§

fn expires_seconds(self, seconds: u32) -> T

Add an Expires header with a specified number of seconds Read more
Source§

fn expires_duration(self, duration: Duration) -> T

Add an Expires header with a specified Duration Read more
Source§

fn expires_zero(self) -> T

Add an Expires header with zero value for immediate expiration Read more
Source§

fn expires_one_hour(self) -> T

Add an Expires header with a standard one-hour expiration Read more
Source§

fn expires_one_day(self) -> T

Add an Expires header with a standard one-day expiration Read more
Source§

impl<T> ExpiresExt for T
where T: HeaderSetter,

Source§

fn expires(self, delta_seconds: u32) -> T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InReplyToBuilderExt for T
where T: HeaderSetter,

Source§

fn in_reply_to(self, call_id: &str) -> T

Add an In-Reply-To header with a single Call-ID Read more
Source§

fn in_reply_to_multiple(self, call_ids: Vec<&str>) -> T

Add an In-Reply-To header with multiple Call-IDs 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> MinSEBuilderExt for T
where T: HeaderSetter,

Source§

fn min_se(self, delta_seconds: u32) -> T

Sets the Min-SE header with the specified delta-seconds value. Read more
Source§

impl<T> OrganizationBuilderExt for T
where T: HeaderSetter,

Source§

fn organization<S>(self, name: S) -> T
where S: Into<String>,

Add an Organization header with the specified organization name Read more
Source§

impl<T> PathBuilderExt for T
where T: HeaderSetter,

Source§

fn path(self, uri: impl AsRef<str>) -> Result<T, Error>

Add a Path header with a single URI Read more
Source§

fn path_addresses(self, uris: Vec<impl AsRef<str>>) -> Result<T, Error>

Add a Path header with multiple URIs Read more
Source§

impl<T> PriorityBuilderExt for T
where T: HeaderSetter,

Source§

fn priority(self, priority: Priority) -> T

Add a Priority header with the specified priority value Read more
Source§

fn priority_emergency(self) -> T

Add a Priority header with emergency priority Read more
Source§

fn priority_urgent(self) -> T

Add a Priority header with urgent priority Read more
Source§

fn priority_normal(self) -> T

Add a Priority header with normal priority Read more
Source§

fn priority_non_urgent(self) -> T

Add a Priority header with non-urgent priority Read more
Source§

fn priority_numeric(self, value: u8) -> T

Add a Priority header with a numeric priority value Read more
Source§

fn priority_token(self, token: impl Into<String>) -> T

Add a Priority header with a custom token value Read more
Source§

impl<T> ProxyAuthenticateExt for T
where T: HeaderSetter,

Source§

fn proxy_authenticate_digest( self, realm: &str, nonce: &str, opaque: Option<&str>, algorithm: Option<&str>, qop: Option<Vec<&str>>, stale: Option<bool>, domain: Option<Vec<&str>>, ) -> T

Add a Digest Proxy-Authenticate header to the response Read more
Source§

fn proxy_authenticate_basic(self, realm: &str) -> T

Add a Basic Proxy-Authenticate header to the response Read more
Source§

impl<T> ProxyAuthorizationExt for T
where T: HeaderSetter,

Source§

fn proxy_authorization_digest( self, username: &str, realm: &str, nonce: &str, uri_str: &str, response: &str, algorithm: Option<&str>, cnonce: Option<&str>, opaque: Option<&str>, qop: Option<&str>, nc: Option<&str>, ) -> T

Add a Digest Proxy-Authorization header to the request Read more
Source§

fn proxy_authorization_basic(self, username: &str, password: &str) -> T

Add a Basic Proxy-Authorization header to the request Read more
Source§

impl<T> ProxyRequireBuilderExt for T
where T: HeaderSetter,

Source§

fn proxy_require_tag(self, option_tag: impl Into<String>) -> T

Add a Proxy-Require header with a single option tag Read more
Source§

fn proxy_require_tags(self, option_tags: Vec<impl Into<String>>) -> T

Add a Proxy-Require header with multiple option tags Read more
Source§

fn proxy_require_sec_agree(self) -> T

Add a Proxy-Require header for sec-agree (security agreement) Read more
Source§

fn proxy_require_precondition(self) -> T

Add a Proxy-Require header for precondition Read more
Source§

fn proxy_require_path(self) -> T

Add a Proxy-Require header for path Read more
Source§

fn proxy_require_resource_priority(self) -> T

Add a Proxy-Require header for resource priority Read more
Source§

impl<T> RSeqBuilderExt for T
where T: HeaderSetter,

Source§

fn rseq(self, seq: u32) -> T

Add an RSeq header with a sequence number Read more
Source§

fn rseq_next(self, previous_seq: u32) -> T

Add an RSeq header with a sequence number incremented from a previous value Read more
Source§

impl<T> ReasonBuilderExt for T
where T: HeaderSetter,

Source§

fn reason( self, protocol: impl Into<String>, cause: u16, text: Option<impl Into<String>>, ) -> T

Add a Reason header with the specified protocol, cause code, and optional text Read more
Source§

fn reason_sip(self, cause: u16, text: Option<impl Into<String>>) -> T

Add a Reason header with SIP protocol and the specified cause code and text Read more
Source§

fn reason_q850(self, cause: u16, text: Option<impl Into<String>>) -> T

Add a Reason header with Q.850 protocol and the specified cause code and text Read more
Source§

fn reason_terminated(self) -> T

Add a Reason header for SIP request termination Read more
Source§

fn reason_busy(self) -> T

Add a Reason header for busy indication Read more
Source§

fn reason_normal_clearing(self) -> T

Add a Reason header for normal call clearing Read more
Source§

fn reason_declined(self) -> T

Add a Reason header for call rejected/declined Read more
Source§

impl<T> RecordRouteBuilderExt for T
where T: HeaderSetter,

Source§

fn record_route_uri(self, uri: Uri) -> T

Add a Record-Route header with URI Read more
Source§

fn record_route_address(self, address: Address) -> T

Add a Record-Route header with Address Read more
Source§

fn record_route_entry(self, entry: RecordRouteEntry) -> T

Add a Record-Route header with a raw entry Read more
Source§

fn record_route_entries(self, entries: Vec<RecordRouteEntry>) -> T

Add a Record-Route header with multiple entries Read more
Source§

impl<T> ReferToExt for T
where T: HeaderSetter,

Source§

fn refer_to_uri(self, uri: impl Into<String>) -> T

Add a Refer-To header with a URI Read more
Source§

fn refer_to_address( self, display_name: impl Into<String>, uri: impl Into<String>, ) -> T

Add a Refer-To header with a URI and display name Read more
Source§

fn refer_to_with_address(self, address: Address) -> T

Add a Refer-To header with a prebuilt Address object Read more
Source§

fn refer_to_blind_transfer(self, target_uri: impl Into<String>) -> T

Add a Refer-To header for a blind transfer Read more
Source§

fn refer_to_attended_transfer( self, target_uri: impl Into<String>, call_id: impl Into<String>, to_tag: impl Into<String>, from_tag: impl Into<String>, ) -> T

Add a Refer-To header for an attended transfer with Replaces Read more
Source§

impl<T> ReferredByExt for T
where T: HeaderSetter,

Source§

fn referred_by(self, address: Address) -> T

Add a Referred-By header with the given Address. Read more
Source§

fn referred_by_uri(self, uri: Uri) -> T

Add a Referred-By header with the given URI. Read more
Source§

fn referred_by_str(self, value: &str) -> Result<T, Error>

Add a Referred-By header parsed from a string. Read more
Source§

fn referred_by_uri_with_cid(self, uri: Uri, cid: Option<&str>) -> T

Add a Referred-By header with URI and optional cid parameter. Read more
Source§

fn referred_by_with_cid(self, address: Address, cid: Option<&str>) -> T

Add a Referred-By header with Address and optional cid parameter. Read more
Source§

impl<T> ReplyToBuilderExt for T
where T: HeaderSetter,

Source§

fn reply_to(self, uri_str: &str) -> Result<T, Error>

Set a Reply-To header using a URI string Read more
Source§

fn reply_to_with_display_name( self, display_name: &str, uri_str: &str, ) -> Result<T, Error>

Set a Reply-To header using a URI string and display name Read more
Source§

fn reply_to_address(self, address: Address) -> T

Set a Reply-To header using a pre-constructed Address Read more
Source§

impl<T> RequireBuilderExt for T
where T: HeaderSetter,

Source§

fn require_tag(self, option_tag: impl Into<String>) -> T

Add a Require header with a single option tag Read more
Source§

fn require_tags(self, option_tags: Vec<impl Into<String>>) -> T

Add a Require header with multiple option tags Read more
Source§

fn require_100rel(self) -> T

Add a Require header for 100rel (reliable provisional responses) Read more
Source§

fn require_timer(self) -> T

Add a Require header for timer (session timers) Read more
Source§

fn require_path(self) -> T

Add a Require header for path Read more
Source§

fn require_ice(self) -> T

Add a Require header for ICE negotiation Read more
Source§

fn require_webrtc(self) -> T

Add a Require header with common WebRTC-related option tags Read more
Source§

impl<T> RetryAfterBuilderExt for T
where T: HeaderSetter,

Source§

fn retry_after(self, seconds: u32) -> T

Add a Retry-After header with a delay in seconds Read more
Source§

fn retry_after_from_duration(self, duration: Duration) -> T

Add a Retry-After header with a delay specified as a Duration Read more
Source§

fn retry_after_with_comment(self, seconds: u32, comment: &str) -> T

Add a Retry-After header with a delay and a comment Read more
Source§

fn retry_after_duration( self, seconds: u32, duration: u32, comment: Option<&str>, ) -> T

Add a Retry-After header with a delay, duration parameter, and optional comment Read more
Source§

fn retry_after_duration_with_comment( self, duration: Duration, comment: &str, ) -> T

Add a Retry-After header with a Duration and a comment Read more
Source§

impl<T> ServerBuilderExt for T
where T: HeaderSetter,

Source§

fn server(self, product: impl Into<String>) -> T

Add a Server header with a single product token Read more
Source§

fn server_products(self, products: Vec<impl Into<String>>) -> T

Add a Server header with multiple product tokens Read more
Source§

impl<T> SessionExpiresExt for T
where T: HeaderSetter,

Source§

fn session_expires(self, delta_seconds: u32, refresher: Option<Refresher>) -> T

Sets the Session-Expires header with the given interval and optional refresher. Read more
Source§

fn session_expires_with_params( self, delta_seconds: u32, refresher: Option<Refresher>, params: Vec<Param>, ) -> T

Sets the Session-Expires header with interval, optional refresher, and additional generic parameters. Read more
Source§

fn session_expires_uac(self, delta_seconds: u32) -> T

Convenience method to set Session-Expires with UAC (User Agent Client) as the refresher. Read more
Source§

fn session_expires_uas(self, delta_seconds: u32) -> T

Convenience method to set Session-Expires with UAS (User Agent Server) as the refresher. Read more
Source§

impl<T> SupportedBuilderExt for T
where T: HeaderSetter,

Source§

fn supported_tag(self, option_tag: impl Into<String>) -> T

Add a Supported header with a single option tag Read more
Source§

fn supported_tags(self, option_tags: Vec<impl Into<String>>) -> T

Add a Supported header with multiple option tags Read more
Source§

fn supported_100rel(self) -> T

Add a Supported header for 100rel (reliable provisional responses) Read more
Source§

fn supported_path(self) -> T

Add a Supported header for path Read more
Source§

fn supported_timer(self) -> T

Add a Supported header for timer Read more
Source§

fn supported_webrtc(self) -> T

Add a Supported header with common WebRTC-related option tags Read more
Source§

fn supported_standard(self) -> T

Add a Supported header with standard option tags used by UAs 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<T> UnsupportedBuilderExt for T
where T: HeaderSetter,

Source§

fn unsupported_tag(self, option_tag: impl Into<String>) -> T

Add an Unsupported header with a single option tag Read more
Source§

fn unsupported_tags(self, option_tags: Vec<impl Into<String>>) -> T

Add an Unsupported header with multiple option tags Read more
Source§

fn unsupported_100rel(self) -> T

Add an Unsupported header for 100rel (reliable provisional responses) Read more
Source§

fn unsupported_timer(self) -> T

Add an Unsupported header for timer Read more
Source§

fn unsupported_path(self) -> T

Add an Unsupported header for path Read more
Source§

impl<T> UserAgentBuilderExt for T
where T: HeaderSetter,

Source§

fn user_agent(self, product: impl Into<String>) -> T

Add a User-Agent header with a single product token Read more
Source§

fn user_agent_products(self, products: Vec<impl Into<String>>) -> T

Add a User-Agent header with multiple product tokens Read more
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WarningBuilderExt for T
where T: HeaderSetter,

Source§

fn warning(self, code: u16, agent: Uri, text: impl Into<String>) -> T

Add a Warning header with the specified warning code, agent, and text Read more
Source§

fn warnings(self, warnings: Vec<Warning>) -> T

Add multiple warnings to a message Read more
Source§

fn warning_incompatible_protocol(self, text: impl Into<String>) -> T

Add a Warning header for incompatible network protocol (300) Read more
Source§

fn warning_incompatible_address_format(self, text: impl Into<String>) -> T

Add a Warning header for incompatible network address formats (301) Read more
Source§

fn warning_incompatible_transport(self, text: impl Into<String>) -> T

Add a Warning header for incompatible transport protocol (302) Read more
Source§

fn warning_incompatible_media_format(self, text: impl Into<String>) -> T

Add a Warning header for incompatible media format (305) Read more
Source§

fn warning_insufficient_bandwidth(self, text: impl Into<String>) -> T

Add a Warning header for insufficient bandwidth (370) Read more
Source§

fn warning_miscellaneous(self, text: impl Into<String>) -> T

Add a Warning header for miscellaneous warning (399) Read more
Source§

impl<T> WwwAuthenticateExt for T
where T: HeaderSetter,

Source§

fn www_authenticate_digest( self, realm: &str, nonce: &str, opaque: Option<&str>, algorithm: Option<&str>, qop: Option<Vec<&str>>, stale: Option<bool>, domain: Option<Vec<&str>>, ) -> T

Add a Digest WWW-Authenticate header to the response Read more
Source§

fn www_authenticate_basic(self, realm: &str) -> T

Add a Basic WWW-Authenticate header to the response Read more