[−][src]Enum rhymessage::HeaderMultiMode
This enumerates the ways in which a multi-value header may be represented in the generated text.
Variants
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() );
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
impl Clone for HeaderMultiMode
[src]
fn clone(&self) -> HeaderMultiMode
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for HeaderMultiMode
[src]
impl Debug for HeaderMultiMode
[src]
Auto Trait Implementations
impl RefUnwindSafe for HeaderMultiMode
impl Send for HeaderMultiMode
impl Sync for HeaderMultiMode
impl Unpin for HeaderMultiMode
impl UnwindSafe for HeaderMultiMode
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,