[−][src]Struct media_type::Value
A parameter value section of a Mime
.
Except for the charset
parameter, parameters
are compared case sensitive
Methods
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::<mime::Mime>().unwrap(); let param = mime.get_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
use std::borrow::Cow; let raw_mime = r#"text/plain; p1="char is \""; p2="simple"; p3=simple2"#; let mime = raw_mime.parse::<mime::Mime>().unwrap(); let param1 = mime.get_param("p1").unwrap(); let expected: Cow<'static, str> = Cow::Owned(r#"char is ""#.into()); assert_eq!(param1.to_content(), expected); let param2 = mime.get_param("p2").unwrap(); assert_eq!(param2.to_content(), Cow::Borrowed("simple")); let param3 = mime.get_param("p3").unwrap(); assert_eq!(param3.to_content(), Cow::Borrowed("simple2"));
pub fn is_quoted(&self) -> bool
[src]
Trait Implementations
impl<'a> From<Value<'a>> for Cow<'a, str>
[src]
impl<'a> Clone for Value<'a>
[src]
impl<'a> Copy for Value<'a>
[src]
impl<'a> Eq for Value<'a>
[src]
impl<'a, 'b> PartialEq<Value<'b>> for Value<'a>
[src]
impl<'a> PartialEq<str> for Value<'a>
[src]
impl<'a, 'b> PartialEq<&'b str> for Value<'a>
[src]
impl<'a, 'b> PartialEq<Value<'b>> for &'a str
[src]
impl<'a> PartialEq<Value<'a>> for str
[src]
impl<'a> Debug for Value<'a>
[src]
impl<'a> Hash for Value<'a>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, 'b> AsciiCaseInsensitiveEq<Value<'b>> for Value<'a>
[src]
fn eq_ignore_ascii_case(&self, other: &Value<'b>) -> bool
[src]
impl<'a> AsciiCaseInsensitiveEq<str> for Value<'a>
[src]
fn eq_ignore_ascii_case(&self, other: &str) -> bool
[src]
impl<'a> AsciiCaseInsensitiveEq<Value<'a>> for str
[src]
fn eq_ignore_ascii_case(&self, other: &Value<'a>) -> bool
[src]
impl<'a, 'b> AsciiCaseInsensitiveEq<&'b str> for Value<'a>
[src]
fn eq_ignore_ascii_case(&self, other: &&'b str) -> bool
[src]
impl<'a, 'b> AsciiCaseInsensitiveEq<Value<'a>> for &'b str
[src]
fn eq_ignore_ascii_case(&self, other: &Value<'a>) -> bool
[src]
Auto Trait Implementations
impl<'a> Send for Value<'a>
impl<'a> Sync for Value<'a>
impl<'a> Unpin for Value<'a>
impl<'a> UnwindSafe for Value<'a>
impl<'a> RefUnwindSafe for Value<'a>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,