more naming improvements
All checks were successful
Rust/spacepackets/pipeline/pr-main This commit looks good
Rust/spacepackets/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2024-03-14 16:59:58 +01:00
parent fa450c3445
commit 9cbdd30939
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 13 additions and 13 deletions

View File

@ -188,7 +188,7 @@ pub struct CdsTime<DaysLen: ProvidesDaysLength = DaysLen16Bits> {
submillis: u32,
/// This is not strictly necessary but still cached because it significantly simplifies the
/// calculation of [`DateTime<Utc>`].
unix_stamp: UnixTime,
unix_time: UnixTime,
}
/// Common properties for all CDS time providers.
@ -641,7 +641,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CdsTime<ProvidesDaysLen> {
if let Some(precision) = self.precision_as_ns() {
subsec_nanos += precision;
}
self.unix_stamp = UnixTime::new(unix_days_seconds, subsec_nanos);
self.unix_time = UnixTime::new(unix_days_seconds, subsec_nanos);
}
fn length_check(&self, buf: &[u8], len_as_bytes: usize) -> Result<(), TimestampError> {
@ -668,7 +668,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CdsTime<ProvidesDaysLen> {
pfield: Self::generate_p_field(days_len, SubmillisPrecision::Absent),
ccsds_days,
ms_of_day,
unix_stamp: Default::default(),
unix_time: Default::default(),
submillis: 0,
};
let unix_days_seconds = ccsds_to_unix_days(i64::from(ccsds_days)) * SECONDS_PER_DAY as i64;
@ -748,7 +748,7 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CdsTime<ProvidesDaysLen> {
pfield: Self::generate_p_field(days_len, converter.submillis_precision()),
ccsds_days,
ms_of_day: converter.ms_of_day(),
unix_stamp: Default::default(),
unix_time: Default::default(),
submillis: converter.submillis(),
};
provider.setup(converter.unix_days_seconds(), converter.ms_of_day());
@ -1201,16 +1201,16 @@ impl<ProvidesDaysLen: ProvidesDaysLength> CcsdsTimeProvider for CdsTime<Provides
#[inline]
fn unix_secs(&self) -> i64 {
self.unix_stamp.secs
self.unix_time.secs
}
#[inline]
fn subsec_nanos(&self) -> u32 {
self.unix_stamp.subsec_nanos
self.unix_time.subsec_nanos
}
#[inline]
fn unix_stamp(&self) -> UnixTime {
self.unix_stamp
fn unix_time(&self) -> UnixTime {
self.unix_time
}
}
@ -1357,7 +1357,7 @@ mod tests {
#[test]
fn test_time_stamp_zero_args() {
let time_stamper = CdsTime::new_with_u16_days(0, 0);
let unix_stamp = time_stamper.unix_stamp();
let unix_stamp = time_stamper.unix_time();
assert_eq!(
unix_stamp.secs,
(DAYS_CCSDS_TO_UNIX * SECONDS_PER_DAY as i32) as i64
@ -1386,7 +1386,7 @@ mod tests {
#[test]
fn test_time_stamp_unix_epoch() {
let time_stamper = CdsTime::new_with_u16_days((-DAYS_CCSDS_TO_UNIX) as u16, 0);
assert_eq!(time_stamper.unix_stamp().secs, 0);
assert_eq!(time_stamper.unix_time().secs, 0);
assert_eq!(
time_stamper.submillis_precision(),
SubmillisPrecision::Absent
@ -1463,7 +1463,7 @@ mod tests {
fn test_write() {
let mut buf = [0; 16];
let time_stamper_0 = CdsTime::new_with_u16_days(0, 0);
let unix_stamp = time_stamper_0.unix_stamp();
let unix_stamp = time_stamper_0.unix_time();
assert_eq!(
unix_stamp.secs,
(DAYS_CCSDS_TO_UNIX * SECONDS_PER_DAY as i32).into()
@ -2295,7 +2295,7 @@ mod tests {
fn test_update_from_now() {
let mut stamp = CdsTime::new_with_u16_days(0, 0);
let _ = stamp.update_from_now();
let dt = stamp.unix_stamp().chrono_date_time().unwrap();
let dt = stamp.unix_time().chrono_date_time().unwrap();
assert!(dt.year() > 2020);
}

View File

@ -233,7 +233,7 @@ pub trait CcsdsTimeProvider {
(self.subsec_nanos() / 1_000_000) as u16
}
fn unix_stamp(&self) -> UnixTime {
fn unix_time(&self) -> UnixTime {
UnixTime::new(self.unix_secs(), self.subsec_nanos())
}