pub struct ParsedSipMessage {
pub direction: Direction,
pub transport: Transport,
pub address: String,
pub timestamp: Timestamp,
pub message_type: SipMessageType,
pub headers: Headers,
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: DirectionWhether this message was received or sent.
transport: TransportTransport protocol.
address: StringRemote address as ip:port.
timestamp: TimestampWhen this message was logged.
message_type: SipMessageTypeParsed request or response first line.
headers: HeadersMessage headers in wire order.
body: Vec<u8>Raw body bytes after the \r\n\r\n header terminator.
frame_count: usizeNumber of Level 1 frames that were reassembled into this message.
Implementations§
Source§impl ParsedSipMessage
impl ParsedSipMessage
Sourcepub fn media_type(&self) -> Option<Cow<'_, str>>
pub fn media_type(&self) -> Option<Cow<'_, str>>
Content-Type with parameters stripped and lowercased, e.g.
multipart/mixed from multipart/mixed;boundary=abc. Use this to
dispatch on the type rather than matching the raw header value.
Sourcepub fn is_multipart(&self) -> bool
pub fn is_multipart(&self) -> bool
Returns true if the Content-Type starts with multipart/.
Sourcepub fn multipart_boundary(&self) -> Option<&str>
pub fn multipart_boundary(&self) -> Option<&str>
Extract the MIME boundary string from the Content-Type header.
Sourcepub fn body_parts(&self) -> Option<Vec<MimePart>>
pub fn body_parts(&self) -> Option<Vec<MimePart>>
Split a multipart body into individual MimeParts.
Returns None when the Content-Type carries no boundary parameter or
that boundary yields no parts.
Sourcepub fn body_as_parts(&self) -> Vec<MimePart>
pub fn body_as_parts(&self) -> Vec<MimePart>
The body as parts, whatever its Content-Type: the multipart children
when it splits, otherwise a single part carrying the message’s own
Content-* headers. Empty when there is no body.
That single part is fabricated — a non-multipart body has no per-part
header block on the wire — so its headers are copied down from the
message, compact forms expanded, Content-Length excluded. A part
split from a real multipart body carries only what the sender wrote
there, and nothing is copied into it.
A body that claims multipart/* but does not split — no boundary
parameter, or one that never appears in the body — comes back as that
one part, still typed multipart/*. A caller that only handles types it
recognizes then sees an unknown type rather than nothing at all.
Descends one level only; nested multipart parts are split by calling
MimePart::body_parts on them.
Sourcepub fn body_text(&self) -> Cow<'_, str>
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.
Sourcepub fn json_field(&self, key: &str) -> Option<String>
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
impl ParsedSipMessage
Sourcepub fn socket_addr(&self) -> Option<SocketAddr>
pub fn socket_addr(&self) -> Option<SocketAddr>
The remote address as a typed SocketAddr, preserving family and
port. None when the recorded address is not ip:port; the raw string
remains in address.
Sourcepub fn call_id(&self) -> Option<&str>
pub fn call_id(&self) -> Option<&str>
Returns the Call-ID header value. Checks both Call-ID and
the compact form i.
Sourcepub fn content_type(&self) -> Option<&str>
pub fn content_type(&self) -> Option<&str>
Returns the Content-Type header value. Checks both Content-Type and
the compact form c.
Sourcepub fn content_length(&self) -> Option<usize>
pub fn content_length(&self) -> Option<usize>
Returns the Content-Length header value as usize. Checks both
Content-Length and the compact form l.
Sourcepub fn method(&self) -> Option<&str>
pub fn method(&self) -> Option<&str>
Returns the SIP method: from the request line for requests, or from the CSeq header for responses.
Sourcepub fn body_data(&self) -> Cow<'_, str>
pub fn body_data(&self) -> Cow<'_, str>
Raw body bytes interpreted as UTF-8 (lossy). No processing is applied regardless of Content-Type.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Reconstruct the SIP message as wire-format bytes (first line + headers + body).
Sourcepub fn header_value(&self, name: &str) -> Option<&str>
pub fn header_value(&self, name: &str) -> Option<&str>
Case-insensitive header lookup, first match in wire order. Compact forms are not resolved; the typed accessors above check both names.
Trait Implementations§
Source§impl Clone for ParsedSipMessage
impl Clone for ParsedSipMessage
Source§fn clone(&self) -> ParsedSipMessage
fn clone(&self) -> ParsedSipMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more