5 Commits

Author SHA1 Message Date
b9cd08cefe Merge branch 'main' into all_features
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
2022-12-19 11:03:46 +01:00
976fe9c49b README updates
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
2022-12-19 11:02:36 +01:00
fbeea41e8f fix in Cargo.toml file 2022-12-19 11:00:45 +01:00
0073db95f9 Merge branch 'add_cuc_time_impl' into all_features
All checks were successful
Rust/spacepackets/pipeline/head This commit looks good
2022-12-19 00:01:28 +01:00
177ddba9c5 clippy fixes
Some checks failed
Rust/spacepackets/pipeline/head This commit looks good
Rust/spacepackets/pipeline/pr-main There was a failure building this commit
2022-12-19 00:01:07 +01:00
6 changed files with 20 additions and 15 deletions

View File

@ -35,9 +35,9 @@ default-features = false
version = "1.0"
[features]
default = ["std", "dep:serde"]
default = ["std"]
std = ["chrono/std", "chrono/clock", "alloc"]
serde = ["chrono/serde"]
serde = ["dep:serde", "chrono/serde"]
alloc = ["postcard/alloc", "chrono/alloc"]
[package.metadata.docs.rs]

View File

@ -28,12 +28,15 @@ It also offers optional support for [`serde`](https://serde.rs/). This allows se
deserializing them with an appropriate `serde` provider like
[`postcard`](https://github.com/jamesmunns/postcard).
Default features:
## Default features
- [`std`](https://doc.rust-lang.org/std/): Enables functionality relying on the standard library.
- [`alloc`](https://doc.rust-lang.org/alloc/): Enables features which operate on containers
like [`alloc::vec::Vec`](https://doc.rust-lang.org/beta/alloc/vec/struct.Vec.html).
Enabled by the `std` feature.
## Optional Features
- [`serde`](https://serde.rs/): Adds `serde` support for most types by adding `Serialize` and `Deserialize` `derive`s
# Examples

View File

@ -316,13 +316,13 @@ impl<TYPE: ToBeBytes> EcssEnumeration for GenericEcssEnumWrapper<TYPE> {
}
fn write_to_be_bytes(&self, buf: &mut [u8]) -> Result<(), ByteConversionError> {
if buf.len() < self.byte_width() as usize {
if buf.len() < self.byte_width() {
return Err(ByteConversionError::ToSliceTooSmall(SizeMissmatch {
found: buf.len(),
expected: self.byte_width() as usize,
expected: self.byte_width(),
}));
}
buf[0..self.byte_width() as usize].copy_from_slice(self.val.to_be_bytes().as_ref());
buf[0..self.byte_width()].copy_from_slice(self.val.to_be_bytes().as_ref());
Ok(())
}
}

View File

@ -22,12 +22,15 @@
//! deserializing them with an appropriate `serde` provider like
//! [`postcard`](https://github.com/jamesmunns/postcard).
//!
//! Default features:
//! ### Default features
//!
//! - [`std`](https://doc.rust-lang.org/std/): Enables functionality relying on the standard library.
//! - [`alloc`](https://doc.rust-lang.org/alloc/): Enables features which operate on containers
//! like [`alloc::vec::Vec`](https://doc.rust-lang.org/beta/alloc/vec/struct.Vec.html).
//! Enabled by the `std` feature.
//!
//! ### Optional features
//!
//! - [`serde`](https://serde.rs/): Adds `serde` support for most types by adding `Serialize` and
//! `Deserialize` `derive`s
//!

View File

@ -338,9 +338,8 @@ impl<ProvidesDaysLen: ProvidesDaysLength> TimeProvider<ProvidesDaysLen> {
unix_seconds: 0,
submillis_precision: None,
};
let unix_days_seconds =
ccsds_to_unix_days(ccsds_days.into()) as i64 * SECONDS_PER_DAY as i64;
provider.setup(unix_days_seconds as i64, ms_of_day.into());
let unix_days_seconds = ccsds_to_unix_days(ccsds_days.into()) * SECONDS_PER_DAY as i64;
provider.setup(unix_days_seconds, ms_of_day.into());
Ok(provider)
}
@ -552,7 +551,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CcsdsTimeProvider for TimeProvider<Pro
}
fn date_time(&self) -> Option<DateTime<Utc>> {
self.calc_date_time((self.ms_of_day % 1000) as u32)
self.calc_date_time(self.ms_of_day % 1000)
}
}

View File

@ -206,7 +206,7 @@ impl TimeProviderCcsdsEpoch {
WidthCounterPair(4, counter),
Some(FractionalPart(
FractionalResolution::SixtyNs,
subsec_fractions as u32,
subsec_fractions,
)),
)
}
@ -431,9 +431,9 @@ impl TimeReader for TimeProviderCcsdsEpoch {
3 => {
let mut tmp_buf: [u8; 4] = [0; 4];
tmp_buf[1..4].copy_from_slice(&buf[current_idx..current_idx + 3]);
u32::from_be_bytes(tmp_buf) as u32
u32::from_be_bytes(tmp_buf)
}
4 => u32::from_be_bytes(buf[current_idx..current_idx + 4].try_into().unwrap()) as u32,
4 => u32::from_be_bytes(buf[current_idx..current_idx + 4].try_into().unwrap()),
_ => panic!("unreachable match arm"),
};
current_idx += cntr_len as usize;
@ -458,7 +458,7 @@ impl TimeReader for TimeProviderCcsdsEpoch {
tmp_buf[1..4].copy_from_slice(&buf[current_idx..current_idx + 3]);
fractions = Some(FractionalPart(
fractions_len.try_into().unwrap(),
u32::from_be_bytes(tmp_buf) as u32,
u32::from_be_bytes(tmp_buf),
))
}
_ => panic!("unreachable match arm"),