diff --git a/generator/sbpg/targets/resources/rust/sbp_cargo.toml b/generator/sbpg/targets/resources/rust/sbp_cargo.toml index e9da1b72fd..015fedb4d0 100644 --- a/generator/sbpg/targets/resources/rust/sbp_cargo.toml +++ b/generator/sbpg/targets/resources/rust/sbp_cargo.toml @@ -22,7 +22,7 @@ default = [] async = ["futures", "dencode/async"] serde = ["dep:serde", "serde-big-array"] json = ["serde", "serde_json", "base64"] -float_roundtrip = ["serde_json/float_roundtrip"] +float_roundtrip = ["serde", "serde_json/float_roundtrip"] link = ["slotmap"] [lib] diff --git a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs index d54804610e..edf1f6c69d 100644 --- a/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs +++ b/generator/sbpg/targets/resources/rust/sbp_messages_mod.rs @@ -123,7 +123,7 @@ pub enum Sbp { Unknown( Unknown ), } -#[cfg(feature = "serde")] +#[cfg(feature = "serde_json")] impl<'de> serde::Deserialize<'de> for Sbp { fn deserialize(deserializer: D) -> Result where diff --git a/rust/sbp/Cargo.toml b/rust/sbp/Cargo.toml index fd931fcecb..df5a13af89 100644 --- a/rust/sbp/Cargo.toml +++ b/rust/sbp/Cargo.toml @@ -22,7 +22,7 @@ default = [] async = ["futures", "dencode/async"] serde = ["dep:serde", "serde-big-array"] json = ["serde", "serde_json", "base64"] -float_roundtrip = ["serde_json/float_roundtrip"] +float_roundtrip = ["serde", "serde_json/float_roundtrip"] link = ["slotmap"] [lib] diff --git a/rust/sbp/src/messages/mod.rs b/rust/sbp/src/messages/mod.rs index f33dbd05d1..f7b5f3291c 100644 --- a/rust/sbp/src/messages/mod.rs +++ b/rust/sbp/src/messages/mod.rs @@ -795,7 +795,7 @@ pub enum Sbp { Unknown(Unknown), } -#[cfg(feature = "serde")] +#[cfg(feature = "serde_json")] impl<'de> serde::Deserialize<'de> for Sbp { fn deserialize(deserializer: D) -> Result where diff --git a/rust/sbp/src/sbp_string.rs b/rust/sbp/src/sbp_string.rs index ea56de5ada..71db09635f 100644 --- a/rust/sbp/src/sbp_string.rs +++ b/rust/sbp/src/sbp_string.rs @@ -1,9 +1,8 @@ -use std::convert::TryInto; use std::fmt; -use std::fmt::Formatter; use std::marker::PhantomData; use bytes::{Buf, BufMut}; +#[cfg(feature = "serde")] use serde::de::{Error, Visitor}; use crate::wire_format::WireFormat; @@ -84,7 +83,7 @@ impl<'de, E> serde::Deserialize<'de> for SbpString, E> { impl<'de, E> Visitor<'de> for SbpStringVisitor { type Value = SbpString, E>; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("string") } @@ -126,12 +125,14 @@ impl<'de, E, const LEN: usize> serde::Deserialize<'de> for SbpString<[u8; LEN], where D: serde::Deserializer<'de>, { + use std::convert::TryInto; + struct SbpStringVisitor(PhantomData>); impl<'de, E, const LEN: usize> Visitor<'de> for SbpStringVisitor { type Value = SbpString<[u8; LEN], E>; - fn expecting(&self, formatter: &mut Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { formatter.write_str("string") } diff --git a/scripts/ci_build_rust.bash b/scripts/ci_build_rust.bash index f3835eb59b..dd689eef29 100755 --- a/scripts/ci_build_rust.bash +++ b/scripts/ci_build_rust.bash @@ -24,6 +24,13 @@ else exit 1 fi +cargo build --no-default-features -p sbp +cargo build --no-default-features -p sbp --features serde +cargo build --no-default-features -p sbp --features json +cargo build --no-default-features -p sbp --features async +cargo build --no-default-features -p sbp --features link +cargo build --no-default-features -p sbp --features float_roundtrip + if [ "$RUNNER_OS" == "Linux" ]; then cargo build --all --release --target=x86_64-unknown-linux-musl cd target/x86_64-unknown-linux-musl/release