From a582c246b8648235c503a82ca41fd65da11c7b58 Mon Sep 17 00:00:00 2001 From: NoahSprenger Date: Sat, 5 Oct 2024 14:53:38 -0400 Subject: [PATCH] please --- Cargo.toml | 7 +++++-- src/lib.rs | 14 ++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6f5890d..d78e99b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,14 +17,17 @@ mavlink = { git = "https://github.com/uorocketry/rust-mavlink.git", features = [ bitflags = { version = "2.3.1", features = ["serde"] } proptest = { version = "1.2.0", optional = true } proptest-derive = { version = "0.3.0", optional = true } +proptest-arbitrary-interop = { version = "0.1.0", optional = true } messages-proc-macros-lib = { path = "messages-proc-macros-lib" } -chrono = {git = "https://github.com/uorocketry/chrono", features = ["serde", "arbitrary"], default-features = false} +# chrono = { git = "https://github.com/uorocketry/chrono", features = ["serde", "arbitrary"], default-features = false} +chrono = { path = "C:\\Users\\noahr\\Documents\\Rocketry\\chrono", features = ["serde", "arbitrary"], default-features = false } [dev-dependencies] proptest = "1.2.0" proptest-derive = "0.3.0" postcard = { version = "1.0.4", features = ["alloc"] } +proptest-arbitrary-interop = "0.1.0" [features] default = ["mavlink/embedded-hal-02", "mavlink/uorocketry"] -std = ["chrono/std", "mavlink/std", "mavlink/tcp", "mavlink/udp", "mavlink/direct-serial", "mavlink/serde", "dep:proptest", "dep:proptest-derive"] +std = ["chrono/std", "mavlink/std", "mavlink/tcp", "mavlink/udp", "mavlink/direct-serial", "mavlink/serde", "dep:proptest-arbitrary-interop", "dep:proptest", "dep:proptest-derive"] diff --git a/src/lib.rs b/src/lib.rs index d45b504..1145dd8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ use crate::state::State; use derive_more::From; /// This is to help control versions. pub use mavlink; -use chrono::NaiveDateTime; +use chrono::{NaiveDate, FixedOffset, NaiveDateTime}; use messages_proc_macros_lib::common_derives; pub mod command; @@ -29,6 +29,9 @@ pub use logging::{ErrorContext, Event, Log, LogLevel}; use defmt::Format; #[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +#[cfg_attr(feature = "ts", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts", ts(export))] +#[cfg_attr(all(feature = "std", test), derive(proptest_derive::Arbitrary))] pub struct FormattedNaiveDateTime(pub NaiveDateTime); impl Format for FormattedNaiveDateTime { @@ -39,9 +42,12 @@ impl Format for FormattedNaiveDateTime { /// Topmost message. Encloses all the other possible messages, and is the only thing that should /// be sent over the wire. -#[common_derives(NoFormat)] +#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)] +#[cfg_attr(feature = "ts", derive(ts_rs::TS))] +#[cfg_attr(feature = "ts", ts(export))] +#[cfg_attr(all(feature = "std", test), derive(proptest_derive::Arbitrary))] pub struct Message { - pub timestamp: NaiveDateTime, + pub timestamp: FormattedNaiveDateTime, /// The original sender of this message. pub node: Node, @@ -61,7 +67,7 @@ pub enum Data { } impl Message { - pub fn new(timestamp: NaiveDateTime, node: Node, data: impl Into) -> Self { + pub fn new(timestamp: FormattedNaiveDateTime, node: Node, data: impl Into) -> Self { Message { timestamp, node,