Parrot.Sip.Uri (Parrot Platform v0.0.1-alpha.2)

Represents a SIP URI and provides functions for parsing and manipulating SIP URIs.

Summary

Functions

Decode the user part of the URI, handling percent encoding.

Check if two URIs are equal according to SIP URI comparison rules.

Check if a URI is a SIPS URI.

Create a new SIP URI with the given components.

Parse a SIP URI string into a structured Uri.

Convert a Uri struct back to a string representation.

Add or update a parameter in a URI.

Replace all parameters in a URI.

Add or update a port to a URI.

Types

t()

@type t() :: %Parrot.Sip.Uri{
  headers: map(),
  host: String.t(),
  host_type: :hostname | :ipv4 | :ipv6,
  parameters: map(),
  password: String.t() | nil,
  port: integer() | nil,
  scheme: String.t(),
  user: String.t() | nil
}

Functions

decoded_user(uri)

@spec decoded_user(t()) :: String.t() | nil

Decode the user part of the URI, handling percent encoding.

equal?(uri1, uri2)

@spec equal?(t(), t()) :: boolean()

Check if two URIs are equal according to SIP URI comparison rules.

This implements the URI comparison rules from RFC 3261 section 19.1.4.

is_sips?(uri)

@spec is_sips?(t()) :: boolean()

Check if a URI is a SIPS URI.

new(scheme, user, host, port \\ nil, parameters \\ %{}, headers \\ %{})

@spec new(String.t(), String.t(), String.t(), integer() | nil, map(), map()) :: t()

Create a new SIP URI with the given components.

parse(uri_string)

@spec parse(String.t()) :: {:ok, t()} | {:error, String.t()}

Parse a SIP URI string into a structured Uri.

Returns {:ok, uri} or {:error, reason}.

parse!(uri_string)

to_string(uri)

@spec to_string(t()) :: String.t()

Convert a Uri struct back to a string representation.

with_parameter(uri, name, value)

@spec with_parameter(t(), String.t(), String.t()) :: t()

Add or update a parameter in a URI.

with_parameters(uri, parameters)

@spec with_parameters(t(), map()) :: t()

Replace all parameters in a URI.

with_port(uri, port)

@spec with_port(t(), integer()) :: t()

Add or update a port to a URI.