Skip to main content

ParsedSipMessage

Struct ParsedSipMessage 

Source
pub struct ParsedSipMessage {
    pub direction: Direction,
    pub transport: Transport,
    pub address: String,
    pub timestamp: Timestamp,
    pub message_type: SipMessageType,
    pub headers: Vec<(String, String)>,
    pub body: Vec<u8>,
    pub frame_count: usize,
}
Expand description

A fully parsed SIP message (Level 3 output).

Provides typed access to the request/response line, headers, and body. For JSON content types, body_text() unescapes RFC 8259 string sequences. For multipart bodies, body_parts() splits into individual MIME parts.

Fields§

§direction: Direction

Whether this message was received or sent.

§transport: Transport

Transport protocol.

§address: String

Remote address as ip:port.

§timestamp: Timestamp

When this message was logged.

§message_type: SipMessageType

Parsed request or response first line.

§headers: Vec<(String, String)>

Headers in wire order as (name, value) pairs. Names preserve original casing; lookups are case-insensitive.

§body: Vec<u8>

Raw body bytes after the \r\n\r\n header terminator.

§frame_count: usize

Number of Level 1 frames that were reassembled into this message.

Implementations§

Source§

impl ParsedSipMessage

Source

pub fn is_multipart(&self) -> bool

Returns true if the Content-Type starts with multipart/.

Source

pub fn multipart_boundary(&self) -> Option<&str>

Extract the MIME boundary string from the Content-Type header.

Source

pub fn body_parts(&self) -> Option<Vec<MimePart>>

Split a multipart body into individual MimeParts. Returns None if the message is not multipart.

Source

pub fn body_text(&self) -> Cow<'_, str>

Content-type-aware body text. For JSON content types (application/json and application/*+json), unescapes RFC 8259 string sequences (\r\n to CRLF, \t to tab, \uXXXX to Unicode). Passthrough for all other content types.

Source

pub fn json_field(&self, key: &str) -> Option<String>

Parse the body as JSON and return the unescaped string value of a top-level key. Returns None if the content type is not JSON, the body is invalid JSON, the key is missing, or the value is not a string.

Source§

impl ParsedSipMessage

Source

pub fn call_id(&self) -> Option<&str>

Returns the Call-ID header value. Checks both Call-ID and the compact form i.

Source

pub fn content_type(&self) -> Option<&str>

Returns the Content-Type header value. Checks both Content-Type and the compact form c.

Source

pub fn content_length(&self) -> Option<usize>

Returns the Content-Length header value as usize. Checks both Content-Length and the compact form l.

Source

pub fn cseq(&self) -> Option<&str>

Returns the CSeq header value (e.g., "1 INVITE").

Source

pub fn method(&self) -> Option<&str>

Returns the SIP method: from the request line for requests, or from the CSeq header for responses.

Source

pub fn body_data(&self) -> Cow<'_, str>

Raw body bytes interpreted as UTF-8 (lossy). No processing is applied regardless of Content-Type.

Source

pub fn to_bytes(&self) -> Vec<u8>

Reconstruct the SIP message as wire-format bytes (first line + headers + body).

Trait Implementations§

Source§

impl Clone for ParsedSipMessage

Source§

fn clone(&self) -> ParsedSipMessage

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 ParsedSipMessage

Source§

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

Formats the value using the given formatter. Read more

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<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> 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, 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> 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