plotly / plotly.rs

Plotly for Rust
https://docs.rs/plotly
MIT License
1.01k stars 98 forks source link

Add "with-axum" feature to allow compilation when other dependencies use axum #181

Closed dureuill closed 1 month ago

dureuill commented 4 months ago

Hello,

thanks for developing plotly :heart:

I'm currently trying to use it for a server backend based on axum that also uses askama for templates, and unfortunately that combination results in a compilation error as we run afoul of https://github.com/djc/askama/issues/810:

Compiler errors ```rust error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:14:10 | [package] 14 | #[derive(Template)] | ^^^^^^^^ could not find `askama_axum` in the list of imported crates | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:21:10 | 21 | #[derive(Template)] | ^^^^^^^^ could not find `askama_axum` in the list of imported crates | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:31:10 | 31 | #[derive(Template)] | ^^^^^^^^ could not find `askama_axum` in the list of imported crates | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0433]: failed to resolve: could not find `askama_axum` in the list of imported crates --> /Users/dureuill/.cargo/git/checkouts/plotly-2d2da452b8500b54/0351510/plotly/src/plot.rs:38:10 | 38 | #[derive(Template)] | ^^^^^^^^ could not find `askama_axum` in the list of imported crates | = note: this error originates in the derive macro `Template` (in Nightly builds, run with -Z macro-backtrace for more info) For more information about this error, try `rustc --explain E0433`. error: could not compile `plotly` (lib) due to 4 previous errors ```

To fix these issues, I added the with-axum feature that adds the askama_axum additional dependency when enabled (as well as the with-axum of the askama crate).

Users encountering the compilation errors above need to enable the with-axum feature of plotly to fix the errors. I tested locally and it enables compilation again :+1:

Thanks for reading 🚀

andrei-ng commented 1 month ago

@dureuill , thanks for your PR. Looks good. Will try to get this merged in the next weeks.