-
Hi, I'm trying to make a small (draft) server based on trillium and I have a problem adding TLS: if let Some(tls) = cfg.tls {
server_config = server_config.with_acceptor(RustlsAcceptor::from_single_cert(
tls.cert.as_bytes(),
tls.key.as_bytes(),
));
} I get this error: error[E0308]: mismatched types
--> src/main.rs:79:53
|
79 | server_config = server_config.with_acceptor(RustlsAcceptor::from_single_cert(
| _______________________________________-------------_^
| | |
| | arguments to this function are incorrect
80 | | tls.cert.as_bytes(),
81 | | tls.key.as_bytes(),
82 | | ));
| |_________^ expected `()`, found struct `RustlsAcceptor`
|
note: associated function defined here
--> /home/x/.cargo/registry/src/github.com-1ecc6299db9ec823/trillium-server-common-0.3.0/src/config.rs:126:12
|
126 | pub fn with_acceptor<A: Acceptor<ServerType::Transport>>(
| ^^^^^^^^^^^^^ I understand that Full code is here: https://github.com/treywelsh/fizzbuzz_rs Sorry If I miss something obvious |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! Thanks for using trillium! In this case, the Config does need to contain a generic so the type changes between branches. I was unable to confirm that this works because you have not checked your diff --git forkSrcPrefix/src/main.rs forkDstPrefix/src/main.rs
index e0d380fdcf4250492fe99c46f6117a7a048415f8..cb5fd9dd4c93f22a18f9f59617615fee9b599183 100644
--- forkSrcPrefix/src/main.rs
+++ forkDstPrefix/src/main.rs
@@ -75,20 +75,23 @@ async fn server(cfg: config::Config) -> Result<(), Error> {
server_config = server_config.with_max_connections(cfg.max_conn);
}
+ let app = (
+ Logger::new().with_formatter(apache_common(conn_id, "-")),
+ router,
+ );
+
if let Some(tls) = cfg.tls {
- server_config = server_config.with_acceptor(RustlsAcceptor::from_single_cert(
- tls.cert.as_bytes(),
- tls.key.as_bytes(),
- ));
+ server_config
+ .with_acceptor(RustlsAcceptor::from_single_cert(
+ tls.cert.as_bytes(),
+ tls.key.as_bytes(),
+ ))
+ .run_async(app)
+ .await;
+ } else {
+ server_config.run_async(app).await;
}
- server_config
- .run_async((
- Logger::new().with_formatter(apache_common(conn_id, "-")),
- router,
- ))
- .await;
-
// Terminate the signal stream.
handle.close();
signals_task.await; |
Beta Was this translation helpful? Give feedback.
-
Hi, Thank you very much for your time, it works :) Have a good day :) |
Beta Was this translation helpful? Give feedback.
Hi! Thanks for using trillium! In this case, the Config does need to contain a generic so the type changes between branches.
I was unable to confirm that this works because you have not checked your
Cargo.toml
into the git repository, but I believe that this patch should resolve your issue: