Skip to content

Commit 8653f9a

Browse files
da2ce7josecelano
andcommitted
time extent: rename TimeExtentMaker for clarity
Rename: from `DefaultClockTimeExtentMaker` to `DefaultTimeExtentMaker`, and the associated types. Co-authored-by: Jose Celano <[email protected]>
1 parent 0cab30c commit 8653f9a

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

src/protocol/clock/timeextent.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,23 @@ where
142142
#[derive(Debug)]
143143
pub struct TimeExtentMaker<const CLOCK_TYPE: usize> {}
144144

145-
pub type WorkingClockTimeExtentMaker = TimeExtentMaker<{ ClockType::WorkingClock as usize }>;
146-
pub type StoppedClockTimeExtentMaker = TimeExtentMaker<{ ClockType::StoppedClock as usize }>;
145+
pub type WorkingTimeExtentMaker = TimeExtentMaker<{ ClockType::WorkingClock as usize }>;
146+
pub type StoppedTimeExtentMaker = TimeExtentMaker<{ ClockType::StoppedClock as usize }>;
147147

148-
impl MakeTimeExtent<WorkingClock> for WorkingClockTimeExtentMaker {}
149-
impl MakeTimeExtent<StoppedClock> for StoppedClockTimeExtentMaker {}
148+
impl MakeTimeExtent<WorkingClock> for WorkingTimeExtentMaker {}
149+
impl MakeTimeExtent<StoppedClock> for StoppedTimeExtentMaker {}
150150

151151
#[cfg(not(test))]
152-
pub type DefaultClockTimeExtentMaker = WorkingClockTimeExtentMaker;
152+
pub type DefaultTimeExtentMaker = WorkingTimeExtentMaker;
153153

154154
#[cfg(test)]
155-
pub type DefaultClockTimeExtentMaker = StoppedClockTimeExtentMaker;
155+
pub type DefaultTimeExtentMaker = StoppedTimeExtentMaker;
156156

157157
#[cfg(test)]
158158
mod test {
159159

160160
use crate::protocol::clock::timeextent::{
161-
checked_duration_from_nanos, DefaultClockTimeExtentMaker, Extent, MakeTimeExtent, TimeExtent, TimeExtentBase,
161+
checked_duration_from_nanos, DefaultTimeExtentMaker, Extent, MakeTimeExtent, TimeExtent, TimeExtentBase,
162162
TimeExtentProduct,
163163
};
164164
use crate::protocol::clock::{DefaultClock, DurationSinceUnixEpoch, StoppedTime};
@@ -389,7 +389,7 @@ mod test {
389389
#[test]
390390
fn it_should_return_a_time_extent() {
391391
assert_eq!(
392-
DefaultClockTimeExtentMaker::now(&TIME_EXTENT_VAL.increment).unwrap().unwrap(),
392+
DefaultTimeExtentMaker::now(&TIME_EXTENT_VAL.increment).unwrap().unwrap(),
393393
TimeExtent {
394394
increment: TIME_EXTENT_VAL.increment,
395395
amount: 0
@@ -399,21 +399,21 @@ mod test {
399399
DefaultClock::local_set(&DurationSinceUnixEpoch::from_secs(TIME_EXTENT_VAL.amount * 2));
400400

401401
assert_eq!(
402-
DefaultClockTimeExtentMaker::now(&TIME_EXTENT_VAL.increment).unwrap().unwrap(),
402+
DefaultTimeExtentMaker::now(&TIME_EXTENT_VAL.increment).unwrap().unwrap(),
403403
TIME_EXTENT_VAL
404404
);
405405
}
406406

407407
#[test]
408408
fn it_should_return_none() {
409-
assert_eq!(DefaultClockTimeExtentMaker::now(&TimeExtentBase::ZERO), None);
409+
assert_eq!(DefaultTimeExtentMaker::now(&TimeExtentBase::ZERO), None);
410410
}
411411

412412
#[test]
413413
fn it_should_return_tryfrom_int_error() {
414414
DefaultClock::local_set(&DurationSinceUnixEpoch::MAX);
415415
assert_eq!(
416-
DefaultClockTimeExtentMaker::now(&TimeExtentBase::from_millis(1))
416+
DefaultTimeExtentMaker::now(&TimeExtentBase::from_millis(1))
417417
.unwrap()
418418
.unwrap_err(),
419419
u64::try_from(u128::MAX).unwrap_err()
@@ -429,35 +429,29 @@ mod test {
429429
#[test]
430430
fn it_should_return_a_time_extent() {
431431
assert_eq!(
432-
DefaultClockTimeExtentMaker::now_after(
433-
&TIME_EXTENT_VAL.increment,
434-
&Duration::from_secs(TIME_EXTENT_VAL.amount * 2)
435-
)
436-
.unwrap()
437-
.unwrap(),
432+
DefaultTimeExtentMaker::now_after(&TIME_EXTENT_VAL.increment, &Duration::from_secs(TIME_EXTENT_VAL.amount * 2))
433+
.unwrap()
434+
.unwrap(),
438435
TIME_EXTENT_VAL
439436
);
440437
}
441438

442439
#[test]
443440
fn it_should_return_none() {
444441
assert_eq!(
445-
DefaultClockTimeExtentMaker::now_after(&TimeExtentBase::ZERO, &Duration::ZERO),
442+
DefaultTimeExtentMaker::now_after(&TimeExtentBase::ZERO, &Duration::ZERO),
446443
None
447444
);
448445

449446
DefaultClock::local_set(&DurationSinceUnixEpoch::MAX);
450-
assert_eq!(
451-
DefaultClockTimeExtentMaker::now_after(&TimeExtentBase::ZERO, &Duration::MAX),
452-
None
453-
);
447+
assert_eq!(DefaultTimeExtentMaker::now_after(&TimeExtentBase::ZERO, &Duration::MAX), None);
454448
}
455449

456450
#[test]
457451
fn it_should_return_tryfrom_int_error() {
458452
DefaultClock::local_set(&DurationSinceUnixEpoch::MAX);
459453
assert_eq!(
460-
DefaultClockTimeExtentMaker::now_after(&TimeExtentBase::from_millis(1), &Duration::ZERO)
454+
DefaultTimeExtentMaker::now_after(&TimeExtentBase::from_millis(1), &Duration::ZERO)
461455
.unwrap()
462456
.unwrap_err(),
463457
u64::try_from(u128::MAX).unwrap_err()
@@ -474,7 +468,7 @@ mod test {
474468
DefaultClock::local_set(&DurationSinceUnixEpoch::MAX);
475469

476470
assert_eq!(
477-
DefaultClockTimeExtentMaker::now_before(
471+
DefaultTimeExtentMaker::now_before(
478472
&TimeExtentBase::from_secs(u32::MAX as u64),
479473
&Duration::from_secs(u32::MAX as u64)
480474
)
@@ -490,12 +484,12 @@ mod test {
490484
#[test]
491485
fn it_should_return_none() {
492486
assert_eq!(
493-
DefaultClockTimeExtentMaker::now_before(&TimeExtentBase::ZERO, &Duration::ZERO),
487+
DefaultTimeExtentMaker::now_before(&TimeExtentBase::ZERO, &Duration::ZERO),
494488
None
495489
);
496490

497491
assert_eq!(
498-
DefaultClockTimeExtentMaker::now_before(&TimeExtentBase::ZERO, &Duration::MAX),
492+
DefaultTimeExtentMaker::now_before(&TimeExtentBase::ZERO, &Duration::MAX),
499493
None
500494
);
501495
}
@@ -504,7 +498,7 @@ mod test {
504498
fn it_should_return_tryfrom_int_error() {
505499
DefaultClock::local_set(&DurationSinceUnixEpoch::MAX);
506500
assert_eq!(
507-
DefaultClockTimeExtentMaker::now_before(&TimeExtentBase::from_millis(1), &Duration::ZERO)
501+
DefaultTimeExtentMaker::now_before(&TimeExtentBase::from_millis(1), &Duration::ZERO)
508502
.unwrap()
509503
.unwrap_err(),
510504
u64::try_from(u128::MAX).unwrap_err()

0 commit comments

Comments
 (0)