pub enum HeaderMultiMode {
OneLine,
MultiLine,
}Expand description
This enumerates the ways in which a multi-value header may be represented in the generated text.
Variants§
OneLine
Put all values in the same header line (possibly folded) and separate the values with commas.
§Examples
use rhymessage::{MessageHeaders, HeaderMultiMode};
let via: Vec<String> = [
"SIP/2.0/UDP server10.biloxi.com ;branch=z9hG4bKnashds8;received=192.0.2.3",
"SIP/2.0/UDP bigbox3.site3.atlanta.com ;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2",
"SIP/2.0/UDP pc33.atlanta.com ;branch=z9hG4bK776asdhds ;received=192.0.2.1"
].iter().map(|s| String::from(*s)).collect();
let mut headers = MessageHeaders::new();
headers.set_header_multi_value("Via", via.clone(), HeaderMultiMode::OneLine);
assert_eq!(
Ok(concat!(
"Via: SIP/2.0/UDP server10.biloxi.com ;branch=z9hG4bKnashds8;received=192.0.2.3,",
"SIP/2.0/UDP bigbox3.site3.atlanta.com ;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2,",
"SIP/2.0/UDP pc33.atlanta.com ;branch=z9hG4bK776asdhds ;received=192.0.2.1\r\n",
"\r\n",
).as_bytes()),
headers.generate().as_deref()
);MultiLine
Put each value in a separate header line (each possibly folded) where all the header lines have the same header name. Note that the higher-layer protocol may have restrictions on what kinds of headers may express multiple values in this way.
§Examples
use rhymessage::{MessageHeaders, HeaderMultiMode};
let via: Vec<String> = [
"SIP/2.0/UDP server10.biloxi.com ;branch=z9hG4bKnashds8;received=192.0.2.3",
"SIP/2.0/UDP bigbox3.site3.atlanta.com ;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2",
"SIP/2.0/UDP pc33.atlanta.com ;branch=z9hG4bK776asdhds ;received=192.0.2.1"
].iter().map(|s| String::from(*s)).collect();
let mut headers = MessageHeaders::new();
headers.set_header_multi_value("Via", via.clone(), HeaderMultiMode::MultiLine);
assert_eq!(
concat!(
"Via: SIP/2.0/UDP server10.biloxi.com ;branch=z9hG4bKnashds8;received=192.0.2.3\r\n",
"Via: SIP/2.0/UDP bigbox3.site3.atlanta.com ;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2\r\n",
"Via: SIP/2.0/UDP pc33.atlanta.com ;branch=z9hG4bK776asdhds ;received=192.0.2.1\r\n",
"\r\n",
).as_bytes(),
headers.generate()?
);Trait Implementations§
Source§impl Clone for HeaderMultiMode
impl Clone for HeaderMultiMode
Source§fn clone(&self) -> HeaderMultiMode
fn clone(&self) -> HeaderMultiMode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HeaderMultiMode
impl Debug for HeaderMultiMode
impl Copy for HeaderMultiMode
Auto Trait Implementations§
impl Freeze for HeaderMultiMode
impl RefUnwindSafe for HeaderMultiMode
impl Send for HeaderMultiMode
impl Sync for HeaderMultiMode
impl Unpin for HeaderMultiMode
impl UnwindSafe for HeaderMultiMode
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