1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-06 06:02:40 +03:00

Box the CLI command futures to reduce the size of the try_main future

This commit is contained in:
Quentin Gliech
2024-07-02 17:15:51 +02:00
parent eff66726d5
commit edb01f1e98

View File

@@ -69,16 +69,18 @@ pub struct Options {
impl Options {
pub async fn run(self, figment: &Figment) -> anyhow::Result<()> {
use Subcommand as S;
// We Box the futures for each subcommand so that we avoid this function being
// big on the stack all the time
match self.subcommand {
Some(S::Config(c)) => c.run(figment).await,
Some(S::Database(c)) => c.run(figment).await,
Some(S::Server(c)) => c.run(figment).await,
Some(S::Worker(c)) => c.run(figment).await,
Some(S::Manage(c)) => c.run(figment).await,
Some(S::Templates(c)) => c.run(figment).await,
Some(S::Debug(c)) => c.run(figment).await,
Some(S::Doctor(c)) => c.run(figment).await,
None => self::server::Options::default().run(figment).await,
Some(S::Config(c)) => Box::pin(c.run(figment)).await,
Some(S::Database(c)) => Box::pin(c.run(figment)).await,
Some(S::Server(c)) => Box::pin(c.run(figment)).await,
Some(S::Worker(c)) => Box::pin(c.run(figment)).await,
Some(S::Manage(c)) => Box::pin(c.run(figment)).await,
Some(S::Templates(c)) => Box::pin(c.run(figment)).await,
Some(S::Debug(c)) => Box::pin(c.run(figment)).await,
Some(S::Doctor(c)) => Box::pin(c.run(figment)).await,
None => Box::pin(self::server::Options::default().run(figment)).await,
}
}