From d81e7a94134f0ccb51efa65d2d45e02a9734c345 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sat, 4 Apr 2026 00:34:55 +0200 Subject: [PATCH] :sparkles!: add async-trait dependency for WebAppExt trait MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add `async_trait` as an optional依赖ency in pmoapp/Cargo.toml - Enable usage of `#[async_trait]` on WebAppExt trait and its impl for Server - Guard async-related code with `#[cfg(feature = "pmoserver")]` --- Cargo.lock | 1 + pmoapp/Cargo.toml | 6 +++++- pmoapp/src/lib.rs | 4 ++++ pmoapp/src/pmoserver_impl.rs | 4 ++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 6d254f59..9d5c22f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3848,6 +3848,7 @@ checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" name = "pmoapp" version = "0.1.0" dependencies = [ + "async-trait", "pmoserver", "rust-embed", ] diff --git a/pmoapp/Cargo.toml b/pmoapp/Cargo.toml index 8b18b4e2..b5c1e0cf 100644 --- a/pmoapp/Cargo.toml +++ b/pmoapp/Cargo.toml @@ -10,6 +10,10 @@ rust-embed = "8.5.0" path = "../pmoserver" optional = true +[dependencies.async-trait] +optional = true +version = "0.1" + [features] default = [] -pmoserver = ["dep:pmoserver"] +pmoserver = ["dep:pmoserver", "dep:async-trait"] diff --git a/pmoapp/src/lib.rs b/pmoapp/src/lib.rs index b527636f..e7213067 100755 --- a/pmoapp/src/lib.rs +++ b/pmoapp/src/lib.rs @@ -237,6 +237,8 @@ //! - [Vue.js Documentation](https://vuejs.org/) //! - [Vite Documentation](https://vitejs.dev/) +#[cfg(feature = "pmoserver")] +use async_trait::async_trait; use rust_embed::RustEmbed; /// Structure représentant l'application web embarquée. @@ -285,6 +287,8 @@ pub struct Webapp; /// } /// } /// ``` +#[cfg(feature = "pmoserver")] +#[async_trait] pub trait WebAppExt { /// Ajoute une Single Page Application au serveur. /// diff --git a/pmoapp/src/pmoserver_impl.rs b/pmoapp/src/pmoserver_impl.rs index bbbbdd41..e083ddb4 100644 --- a/pmoapp/src/pmoserver_impl.rs +++ b/pmoapp/src/pmoserver_impl.rs @@ -27,10 +27,14 @@ //! # } //! ``` +#[cfg(feature = "pmoserver")] +use async_trait::async_trait; use crate::WebAppExt; use pmoserver::Server; use rust_embed::RustEmbed; +#[cfg(feature = "pmoserver")] +#[async_trait] impl WebAppExt for Server { async fn add_webapp(&mut self, path: &str) where