[][src]Enum rhymessage::HeaderMultiMode

pub enum HeaderMultiMode {
    OneLine,
    MultiLine,
}

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

impl Clone for HeaderMultiMode[src]

impl Copy for HeaderMultiMode[src]

impl Debug for HeaderMultiMode[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.