Add From<Mime> under mime03 flag (#676)

Closes #615
This commit is contained in:
Jacob Mischka
2021-10-05 04:22:25 -05:00
committed by GitHub
parent 3e8988ae55
commit af157c5f26
3 changed files with 12 additions and 0 deletions

View File

@@ -78,6 +78,7 @@ name = "transport_smtp"
[features]
default = ["smtp-transport", "pool", "native-tls", "hostname", "r2d2", "builder"]
builder = ["httpdate", "mime", "base64", "fastrand", "quoted_printable"]
mime03 = ["mime"]
# transports
file-transport = ["uuid"]

View File

@@ -85,16 +85,19 @@
//!
//! * **serde**: Serialization/Deserialization of entities
//! * **tracing**: Logging using the `tracing` crate
//! * **mime03**: Allow creating a [`ContentType`] from an existing [mime 0.3] `Mime` struct
//!
//! [`SMTP`]: crate::transport::smtp
//! [`sendmail`]: crate::transport::sendmail
//! [`file`]: crate::transport::file
//! [`ContentType`]: crate::message::header::ContentType
//! [tokio]: https://docs.rs/tokio/1
//! [async-std]: https://docs.rs/async-std/1
//! [ring]: https://github.com/briansmith/ring#ring
//! [ring-support]: https://github.com/briansmith/ring#online-automated-testing
//! [Tokio 1.x]: https://docs.rs/tokio/1
//! [async-std 1.x]: https://docs.rs/async-std/1
//! [mime 0.3]: https://docs.rs/mime/0.3
#![doc(html_root_url = "https://docs.rs/crate/lettre/0.10.0-rc.3")]
#![doc(html_favicon_url = "https://lettre.rs/favicon.ico")]

View File

@@ -67,6 +67,14 @@ impl FromStr for ContentType {
}
}
#[cfg(feature = "mime03")]
#[cfg_attr(docsrs, doc(cfg(feature = "mime03")))]
impl From<Mime> for ContentType {
fn from(mime: Mime) -> Self {
Self::from_mime(mime)
}
}
/// An error occurred while trying to [`ContentType::parse`].
#[derive(Debug)]
pub struct ContentTypeErr(mime::FromStrError);