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: BytesStrImplementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more