Struct neo_mime::Value [−][src]
pub struct Value<'a> { /* fields omitted */ }
A parameter value section of a MediaType
or MediaRange
.
Except for the charset
parameter, parameters are compared case-sensitive.
Implementations
impl<'a> Value<'a>
[src]
impl<'a> Value<'a>
[src]pub fn as_str_repr(&self) -> &'a str
[src]
Returns the underlying representation.
The underlying representation differs from the content, as it can contain quotes surrounding the content and quoted-pairs, even if non of them are necessary to represent the content.
For example the representation r#""a\"\ b""#
corresponds
to the content r#""a" b"#
. Another semantically equivalent
(i.e. with the same content) representation is r#""a\" b""
Example
let mime = r#"text/plain; param="abc def""#.parse::<neo_mime::MediaType>().unwrap(); let param = mime.param("param").unwrap(); assert_eq!(param.as_str_repr(), r#""abc def""#);
pub fn to_content(&self) -> Cow<'a, str>
[src]
Returns the content of this instance.
It differs to the representation in that it will remove the quotation marks from the quoted string and will “unquote” quoted pairs.
If the underlying representation is a quoted string containing
quoted-pairs Cow::Owned
is returned.
If the underlying representation is a quoted-string without
quoted-pairs Cow::Borrowed
is returned as normal
str slicing can be used to strip the surrounding double quoted.
If the underlying representation is not a quoted-string
Cow::Borrowed
is returned, too.
Example
let raw_mime = r#"text/plain; p1="char is \""; p2="simple"; p3=simple2"#; let mime = raw_mime.parse::<neo_mime::MediaType>().unwrap(); let param1 = mime.param("p1").unwrap(); let expected = r#"char is ""#; assert_eq!(param1.to_content(), expected); let param2 = mime.param("p2").unwrap(); assert_eq!(param2.to_content(), "simple"); let param3 = mime.param("p3").unwrap(); assert_eq!(param3.to_content(), "simple2");
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> UnwindSafe for Value<'a>
impl<'a> UnwindSafe for Value<'a>