Struct mime::Value [−][src]
pub struct Value<'a> { /* fields omitted */ }
A parameter value section of a Mime
.
Except for the charset
parameter, parameters
are compared case sensitive
Methods
impl<'a> Value<'a>
[src]
impl<'a> Value<'a>
pub fn as_str_repr(&self) -> &'a str
[src]
pub fn as_str_repr(&self) -> &'a str
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]
pub fn to_content(&self) -> Cow<'a, str>
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"));
Trait Implementations
impl<'a> Clone for Value<'a>
[src]
impl<'a> Clone for Value<'a>
fn clone(&self) -> Value<'a>
[src]
fn clone(&self) -> Value<'a>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl<'a> Copy for Value<'a>
[src]
impl<'a> Copy for Value<'a>
impl<'a> Eq for Value<'a>
[src]
impl<'a> Eq for Value<'a>
impl<'a> PartialOrd for Value<'a>
[src]
impl<'a> PartialOrd for Value<'a>
fn partial_cmp(&self, other: &Value<'a>) -> Option<Ordering>
[src]
fn partial_cmp(&self, other: &Value<'a>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Value<'a>) -> bool
[src]
fn lt(&self, other: &Value<'a>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Value<'a>) -> bool
[src]
fn le(&self, other: &Value<'a>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Value<'a>) -> bool
[src]
fn gt(&self, other: &Value<'a>) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Value<'a>) -> bool
[src]
fn ge(&self, other: &Value<'a>) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<'a> Ord for Value<'a>
[src]
impl<'a> Ord for Value<'a>
fn cmp(&self, other: &Value<'a>) -> Ordering
[src]
fn cmp(&self, other: &Value<'a>) -> Ordering
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.21.0[src]
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
impl<'a> Hash for Value<'a>
[src]
impl<'a> Hash for Value<'a>
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<'a, 'b> PartialEq<Value<'b>> for Value<'a>
[src]
impl<'a, 'b> PartialEq<Value<'b>> for Value<'a>
fn eq(&self, other: &Value<'b>) -> bool
[src]
fn eq(&self, other: &Value<'b>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a> PartialEq<str> for Value<'a>
[src]
impl<'a> PartialEq<str> for Value<'a>
fn eq(&self, other: &str) -> bool
[src]
fn eq(&self, other: &str) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a, 'b> PartialEq<&'b str> for Value<'a>
[src]
impl<'a, 'b> PartialEq<&'b str> for Value<'a>
fn eq(&self, other: &&'b str) -> bool
[src]
fn eq(&self, other: &&'b str) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a, 'b> PartialEq<Value<'b>> for &'a str
[src]
impl<'a, 'b> PartialEq<Value<'b>> for &'a str
fn eq(&self, other: &Value<'b>) -> bool
[src]
fn eq(&self, other: &Value<'b>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a> PartialEq<Value<'a>> for str
[src]
impl<'a> PartialEq<Value<'a>> for str
fn eq(&self, other: &Value<'a>) -> bool
[src]
fn eq(&self, other: &Value<'a>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
fn ne(&self, other: &Rhs) -> bool
This method tests for !=
.
impl<'a> From<Value<'a>> for Cow<'a, str>
[src]
impl<'a> From<Value<'a>> for Cow<'a, str>
impl<'a> Debug for Value<'a>
[src]
impl<'a> Debug for Value<'a>
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl<'a> Display for Value<'a>
[src]
impl<'a> Display for Value<'a>