change multipart::Part::mime() to mime_str()
The mime crate is expecting a breaking change to 0.4, so to remove the public dependency, this method is changed to `mime_str`, which will parse a MIME string instead.
This commit is contained in:
16
src/error.rs
16
src/error.rs
@@ -113,6 +113,7 @@ impl Error {
|
||||
match self.kind {
|
||||
Kind::Http(ref e) => Some(e),
|
||||
Kind::Hyper(ref e) => Some(e),
|
||||
Kind::Mime(ref e) => Some(e),
|
||||
Kind::Url(ref e) => Some(e),
|
||||
Kind::Tls(ref e) => Some(e),
|
||||
Kind::Io(ref e) => Some(e),
|
||||
@@ -193,6 +194,7 @@ impl fmt::Display for Error {
|
||||
match self.kind {
|
||||
Kind::Http(ref e) => fmt::Display::fmt(e, f),
|
||||
Kind::Hyper(ref e) => fmt::Display::fmt(e, f),
|
||||
Kind::Mime(ref e) => fmt::Display::fmt(e, f),
|
||||
Kind::Url(ref e) => fmt::Display::fmt(e, f),
|
||||
Kind::Tls(ref e) => fmt::Display::fmt(e, f),
|
||||
Kind::Io(ref e) => fmt::Display::fmt(e, f),
|
||||
@@ -217,6 +219,7 @@ impl StdError for Error {
|
||||
match self.kind {
|
||||
Kind::Http(ref e) => e.description(),
|
||||
Kind::Hyper(ref e) => e.description(),
|
||||
Kind::Mime(ref e) => e.description(),
|
||||
Kind::Url(ref e) => e.description(),
|
||||
Kind::Tls(ref e) => e.description(),
|
||||
Kind::Io(ref e) => e.description(),
|
||||
@@ -233,6 +236,7 @@ impl StdError for Error {
|
||||
match self.kind {
|
||||
Kind::Http(ref e) => e.cause(),
|
||||
Kind::Hyper(ref e) => e.cause(),
|
||||
Kind::Mime(ref e) => e.cause(),
|
||||
Kind::Url(ref e) => e.cause(),
|
||||
Kind::Tls(ref e) => e.cause(),
|
||||
Kind::Io(ref e) => e.cause(),
|
||||
@@ -252,6 +256,7 @@ impl StdError for Error {
|
||||
pub enum Kind {
|
||||
Http(::http::Error),
|
||||
Hyper(::hyper::Error),
|
||||
Mime(::mime::FromStrError),
|
||||
Url(::url::ParseError),
|
||||
Tls(::native_tls::Error),
|
||||
Io(io::Error),
|
||||
@@ -274,9 +279,14 @@ impl From<::http::Error> for Kind {
|
||||
impl From<::hyper::Error> for Kind {
|
||||
#[inline]
|
||||
fn from(err: ::hyper::Error) -> Kind {
|
||||
match err {
|
||||
other => Kind::Hyper(other),
|
||||
}
|
||||
Kind::Hyper(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<::mime::FromStrError> for Kind {
|
||||
#[inline]
|
||||
fn from(err: ::mime::FromStrError) -> Kind {
|
||||
Kind::Mime(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -191,11 +191,19 @@ impl Part {
|
||||
}
|
||||
}
|
||||
|
||||
/// Tries to set the mime of this part.
|
||||
pub fn mime_str(mut self, mime: &str) -> ::Result<Part> {
|
||||
self.mime = Some(try_!(mime.parse()));
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
/* Re-enable when mime 0.4 is available, with split MediaType/MediaRange.
|
||||
/// Sets the mime, builder style.
|
||||
pub fn mime(mut self, mime: Mime) -> Part {
|
||||
self.mime = Some(mime);
|
||||
self
|
||||
}
|
||||
*/
|
||||
|
||||
/// Sets the filename, builder style.
|
||||
pub fn file_name<T: Into<Cow<'static, str>>>(mut self, filename: T) -> Part {
|
||||
|
||||
Reference in New Issue
Block a user