Problem
When executing dx serve --web I encounter an issue with the derive macros FromSql & ToSql from the crate postgres-types
I've tried multiple ways to solve the issue that lead to multiple issues of their own:
- adding
postgres-types as a simple dependency with derive feature enabled does not work because of multiple compatibility issues (I assume)
15:55:09 [cargo] error: The "wasm_js" backend requires the `wasm_js` feature for `getrandom`. For more information see: https://docs.rs/getrandom/0.3.4/#webassembly-support
--> C:\Users\Loïc\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\getrandom-0.3.4\src\backends.rs:40:17
|
40 | / compile_error!(concat!(
41 | | "The \"wasm_js\" backend requires the `wasm_js` feature \
42 | | for `getrandom`. For more information see: \
43 | | https://docs.rs/getrandom/", env!("CARGO_PKG_VERSION"), "/#webassembly-support"
44 | | ));
| |__________________^
15:55:09 [cargo] error[E0425]: cannot find function `fill_inner` in module `backends`
--> C:\Users\Loïc\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\getrandom-0.3.4\src\lib.rs:99:19
|
99 | backends::fill_inner(dest)?;
| ^^^^^^^^^^ not found in `backends`
15:55:09 [cargo] error[E0425]: cannot find function `inner_u32` in module `backends`
--> C:\Users\Loïc\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\getrandom-0.3.4\src\lib.rs:123:15
|
123 | backends::inner_u32()
| ^^^^^^^^^ not found in `backends`
|
help: consider importing this function
|
33 + use crate::util::inner_u32;
|
help: if you import `inner_u32`, refer to it directly
|
123 - backends::inner_u32()
123 + inner_u32()
|
15:55:09 [cargo] error[E0425]: cannot find function `inner_u64` in module `backends`
--> C:\Users\Loïc\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\getrandom-0.3.4\src\lib.rs:137:15
|
137 | backends::inner_u64()
| ^^^^^^^^^ not found in `backends`
|
help: consider importing this function
|
33 + use crate::util::inner_u64;
|
help: if you import `inner_u64`, refer to it directly
|
137 - backends::inner_u64()
137 + inner_u64()
|
- adding
postgres-types as an optional dependency on the server feature with derive feature enabled does not work either
15:58:26 [cargo] error: cannot find derive macro `ToSql` in this scope
--> src\fluff.rs:16:70
|
16 | #[derive(Debug, Display, EnumString, PartialEq, Eq, PartialOrd, Ord, ToSql)]
| ^^^^^
- without any surprise, adding
postgres-types as an optional dependency on the web feature with derive feature enabled leads to all the same errors as the first method
Relevant code snippets (of the second method)
Enum declaration
#[cfg(feature = "server")]
use postgres_types::ToSql;
#[derive(Debug, Display, EnumString, PartialEq, Eq, PartialOrd, Ord, ToSql)]
pub enum Rarity {
Common,
Uncommon,
Rare,
Epic,
Showcase
}
Cargo.toml
[dependencies]
strum = "0.27"
strum_macros = "0.27"
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.145"
reqwest = "0.12.26"
regex = "1.12.2"
dioxus = { version = "0.7.2", features = ["router", "fullstack"] }
tokio-postgres = { version = "0.7.15", features = ["array-impls"], optional = true }
tokio = { version = "1.48.0", features = ["full"], optional = true }
postgres-types = { version = "0.2.11", features = ["derive"], optional = true }
[features]
default = []
web = ["dioxus/web"]
desktop = ["dioxus/desktop"]
mobile = ["dioxus/mobile"]
server = ["dioxus/server", "dep:tokio-postgres", "dep:tokio", "dep:postgres-types"]
Environment:
- Dioxus version: 0.7.2
- Rust version: rustc 1.92.0 (ded5c06cf 2025-12-08)
- OS info: Microsoft Windows [version 10.0.26200.7462]
- App platform: web
Problem
When executing
dx serve --webI encounter an issue with the derive macros FromSql & ToSql from the crate postgres-typesI've tried multiple ways to solve the issue that lead to multiple issues of their own:
postgres-typesas a simple dependency withderivefeature enabled does not work because of multiple compatibility issues (I assume)postgres-typesas an optional dependency on theserverfeature withderivefeature enabled does not work eitherpostgres-typesas an optional dependency on thewebfeature withderivefeature enabled leads to all the same errors as the first methodRelevant code snippets (of the second method)
Enum declaration
Cargo.toml
Environment: