Struct media_type::MediaType
source · pub struct MediaType<S: Spec> { /* private fields */ }
Implementations
sourceimpl<S> MediaType<S>where
S: Spec,
impl<S> MediaType<S>where
S: Spec,
pub fn parse(input: &str) -> Result<Self, ParserErrorRef<'_>>
pub fn validate(input: &str) -> bool
pub fn new<T, ST>(type_: T, subtype: ST) -> Result<Self, Error>where
T: AsRef<str>,
ST: AsRef<str>,
pub fn new_with_params<T, ST, PI, IN, IV>(
type_: T,
subtype: ST,
params: PI
) -> Result<Self, Error>where
T: AsRef<str>,
ST: AsRef<str>,
PI: IntoIterator<Item = (IN, IV)>,
IN: AsRef<str>,
IV: AsRef<str>,
sourcepub fn remove_param<N>(&mut self, name: N) -> boolwhere
N: for<'a> PartialEq<Name<'a>>,
pub fn remove_param<N>(&mut self, name: N) -> boolwhere
N: for<'a> PartialEq<Name<'a>>,
removes the first param equal to name
, returns true if a parameter was returned
If PartialEq is implemented as excepted at only up to one parameter names can match the given name, through even if more would match the function removes the first match and returns.
If no parameter matches name
nothing is changed and false
is returned.
sourcepub fn set_param<N, V>(&mut self, name: N, value: V)where
N: AsRef<str>,
V: AsRef<str>,
pub fn set_param<N, V>(&mut self, name: N, value: V)where
N: AsRef<str>,
V: AsRef<str>,
set a given parameter to a give value, overriding the old parameter
If there already exists a parameter with the same name the parameter is overridden.
If there the parameter is not part of the media type it is added.
Note that parameters are order-independent given rfc2045, as such the order parameters will have after this function was used is implementation dependent and can change. Mainly this means that this function could replace the parameter in place or could remove it and add the new parameter the end or insert it in the beginning.