Sample SMTP Server (plaintext) in README doesn't compile
Tried with Rust 1.47.0, failed at cargo build
.
Code:
extern crate async_std;
extern crate env_logger;
extern crate samotop;
use samotop::server::Server;
use samotop::service::tcp::dummy::DummyTcpService;
fn main() {
env_logger::init();
let mail = samotop::service::mail::default::DefaultMailService;
let parser = samotop::service::parser::SmtpParser;
let svc = samotop::service::tcp::smtp::SmtpService::new(mail, parser);
let svc = samotop::service::tcp::tls::TlsEnabled::disabled(svc);
let srv = samotop::server::Server::on("localhost:2525").serve(svc);
async_std::task::block_on(srv).unwrap()
}
Output of cargo build
:
$ cargo build
Compiling samotop v0.10.0
error[E0277]: `(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)` cannot be shared between threads safely
--> /Users/zhb/.cargo/registry/src/github.com-1ecc6299db9ec823/samotop-0.10.0/src/service/mail/spf/mod.rs:43:23
|
43 | type MailFuture = MailQueueFut<T::MailFuture>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)` cannot be shared between threads safely
|
::: /Users/zhb/.cargo/registry/src/github.com-1ecc6299db9ec823/samotop-core-0.10.0/src/service/mail/mod.rs:127:67
|
127 | type MailFuture: Future<Output = Option<Self::Mail>> + Send + Sync + 'static;
| ---- required by this bound in `samotop_core::service::mail::MailQueue`
|
= help: the trait `std::marker::Sync` is not implemented for `(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)`
= note: required because of the requirements on the impl of `std::marker::Sync` for `std::ptr::Unique<(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)>`
= note: required because it appears within the type `std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)>`
= note: required because it appears within the type `std::option::Option<std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)>>`
= note: required because it appears within the type `viaspf::Config`
= note: required because it appears within the type `service::mail::spf::MailQueueFut<<T as samotop_core::service::mail::MailQueue>::MailFuture>`
error[E0277]: `(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)` cannot be sent between threads safely
--> /Users/zhb/.cargo/registry/src/github.com-1ecc6299db9ec823/samotop-0.10.0/src/service/mail/spf/mod.rs:43:23
|
43 | type MailFuture = MailQueueFut<T::MailFuture>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)` cannot be sent between threads safely
|
::: /Users/zhb/.cargo/registry/src/github.com-1ecc6299db9ec823/samotop-core-0.10.0/src/service/mail/mod.rs:127:60
|
127 | type MailFuture: Future<Output = Option<Self::Mail>> + Send + Sync + 'static;
| ---- required by this bound in `samotop_core::service::mail::MailQueue`
|
= help: the trait `std::marker::Send` is not implemented for `(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)>`
= note: required because it appears within the type `std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)>`
= note: required because it appears within the type `std::option::Option<std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r mut viaspf::record::ExplainString) + 'static)>>`
= note: required because it appears within the type `viaspf::Config`
= note: required because it appears within the type `service::mail::spf::MailQueueFut<<T as samotop_core::service::mail::MailQueue>::MailFuture>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0277`.
error: could not compile `samotop`.
To learn more, run the command again with --verbose.