Skip to content

Commit

Permalink
please
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSprenger committed Oct 5, 2024
1 parent 48c0c94 commit a582c24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
14 changes: 10 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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,
Expand All @@ -61,7 +67,7 @@ pub enum Data {
}

impl Message {
pub fn new(timestamp: NaiveDateTime, node: Node, data: impl Into<Data>) -> Self {
pub fn new(timestamp: FormattedNaiveDateTime, node: Node, data: impl Into<Data>) -> Self {
Message {
timestamp,
node,
Expand Down

0 comments on commit a582c24

Please sign in to comment.