pub enum FakeClockControlRequest {
Advance {
increment: Increment,
responder: FakeClockControlAdvanceResponder,
},
IncrementMonoToBootOffsetBy {
increment: i64,
responder: FakeClockControlIncrementMonoToBootOffsetByResponder,
},
ResumeWithIncrements {
real: i64,
increment: Increment,
responder: FakeClockControlResumeWithIncrementsResponder,
},
AddStopPoint {
deadline_id: DeadlineId,
event_type: DeadlineEventType,
on_stop: EventPair,
responder: FakeClockControlAddStopPointResponder,
},
Pause {
responder: FakeClockControlPauseResponder,
},
IgnoreNamedDeadline {
deadline_id: DeadlineId,
responder: FakeClockControlIgnoreNamedDeadlineResponder,
},
}Expand description
Provides control over fake clocks.
FakeClockControl provides complete control of the fake clocks that it provides, and serves
over FakeClock.
Upon start up, all the clocks are set to free-running with increments set to 1ms:1ms (same as
calling SetIncrements with a real duration of 1ms and a determined increment of 1ms as
well).
The initial time value for every fake clock is read from the corresponding real clock at start up.
Variants§
Advance
Advances the fake clock increment once. This advances both monotonic and boot clocks by
the same amount.
Returns ZX_ERR_INVALID_ARGS if the provided increment is invalid (such as a badly formed
RandomRange). Returns ZX_ERR_ACCESS_DENIED if called while the FakeClock is free-running.
IncrementMonoToBootOffsetBy
Increments the mono-to-boot offset by the given increment. With real
clocks, the positive offset from monotonic clock to boot clock increases
during suspend. Here, this method fakes such an increase in offset.
increment must be a positive duration.
Returns ZX_ERR_INVALID_ARGS if the provided increment is not positive.
ResumeWithIncrements
Resumes free-running increments on the fake clock.
real is the period based on the real monotonic clock over which increment is going to be
applied. Returns ZX_ERR_INVALID_ARGS if the provided increment is invalid (such as a
badly formed RandomRange).
AddStopPoint
Registers interest in a deadline event.
deadline_id and event_type identify the named deadline and the event associated with
the deadline. When the event occurs, FakeClock will signal EVENTPAIR_SIGNALED on
on_stop. If time is free-running, the clock is stopped. Closing the eventpair cancels
interest in the deadline. If the eventpair is closed when a deadline is reached, time is
not stopped. Note that only events that occur after AddStopPoint is called are matched.
In addition, the EXPIRED event is always reported, even if the component that created the
deadline does not act on the deadline expiration.
The intended use is to set a stop point using AddStopPoint, resume running time with
ResumeWithIncrements, then wait for the stop point to occur using the on_stop
eventpair.
Setting a stop point is only allowed while time is stopped. If time is free running when
this method is invoked ZX_ERR_ACCESS_DENIED is returned. If a stop point is already
registered for the same event, ZX_ALREADY_BOUND is returned.
Fields
deadline_id: DeadlineIdevent_type: DeadlineEventTyperesponder: FakeClockControlAddStopPointResponderPause
Pauses free-running increments on the fake clock.
Fields
responder: FakeClockControlPauseResponderIgnoreNamedDeadline
Instructs the fake clock to make deadlines named deadline_id never expire.
This is a no-op if deadline_id is already in the ignored set.
Implementations§
Source§impl FakeClockControlRequest
impl FakeClockControlRequest
pub fn into_advance( self, ) -> Option<(Increment, FakeClockControlAdvanceResponder)>
pub fn into_increment_mono_to_boot_offset_by( self, ) -> Option<(i64, FakeClockControlIncrementMonoToBootOffsetByResponder)>
pub fn into_resume_with_increments( self, ) -> Option<(i64, Increment, FakeClockControlResumeWithIncrementsResponder)>
pub fn into_add_stop_point( self, ) -> Option<(DeadlineId, DeadlineEventType, EventPair, FakeClockControlAddStopPointResponder)>
pub fn into_pause(self) -> Option<FakeClockControlPauseResponder>
pub fn into_ignore_named_deadline( self, ) -> Option<(DeadlineId, FakeClockControlIgnoreNamedDeadlineResponder)>
Sourcepub fn method_name(&self) -> &'static str
pub fn method_name(&self) -> &'static str
Name of the method defined in FIDL