Skip to main content

Line

Struct Line 

Source
pub struct Line {
    pub name: Name,
    pub value: BytesStr,
}
Expand description

Represents a header header-name: header-value line inside a message

When using PullParser to extract lines from a SIP message this type should be used to parse the Name and remaining value from it.

§Example

use ezk_sip_types::msg::{PullParser, Line};
use ezk_sip_types::Name;
use bytes::Bytes;

let msg = Bytes::from_static( b"REGISTER sips:ss2.biloxi.example.com SIP/2.0
Via: SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7
Max-Forwards: 70
From: Bob <sips:bob@biloxi.example.com>;tag=a73kszlfl
To: Bob <sips:bob@biloxi.example.com>
Call-ID: 1j9FpLxk3uxtm8tn@biloxi.example.com
CSeq: 1 REGISTER
Contact: <sips:bob@client.biloxi.example.com>
Content-Length: 0

");

let mut parser = PullParser::new(&msg, 0);

// skip the first line
parser.next().unwrap();

let via_line = parser.next().unwrap().unwrap();

match Line::parse(&msg, std::str::from_utf8(via_line).unwrap()) {
    Ok((_, line)) => {
        assert_eq!(line.name, Name::VIA);
        assert_eq!(line.value, "SIP/2.0/TLS client.biloxi.example.com:5061;branch=z9hG4bKnashds7")
    }
    Err(e) => panic!("{:?}", e)
}

Fields§

§name: Name§value: BytesStr

Implementations§

Source§

impl Line

Source

pub fn parse<'i>(src: &Bytes, i: &'i str) -> IResult<&'i str, Self>

Auto Trait Implementations§

§

impl !Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnsafeUnpin for Line

§

impl UnwindSafe for Line

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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