pub struct FakeClockController { /* private fields */ }
Expand description
A wrapper around a FakeClockControlProxy
that also allows a client to read
the current fake time.
Implementations§
Source§impl FakeClockController
impl FakeClockController
Sourcepub fn new(
control_proxy: FakeClockControlProxy,
clock_proxy: FakeClockProxy,
) -> Self
pub fn new( control_proxy: FakeClockControlProxy, clock_proxy: FakeClockProxy, ) -> Self
Re-constructs FakeClockController from the constituents.
Sourcepub fn into_components(self) -> (FakeClockControlProxy, FakeClockProxy)
pub fn into_components(self) -> (FakeClockControlProxy, FakeClockProxy)
Deconstructs Self into fake clock proxies.
pub async fn get_monotonic(&self) -> Result<i64, Error>
Sourcepub async fn get_reference(&self) -> Result<BootInstant, Error>
pub async fn get_reference(&self) -> Result<BootInstant, Error>
Returns the current fake instant on the reference timeline.
Methods from Deref<Target = FakeClockControlProxy>§
Sourcepub fn take_event_stream(&self) -> FakeClockControlEventStream
pub fn take_event_stream(&self) -> FakeClockControlEventStream
Get a Stream of events from the remote end of the protocol.
§Panics
Panics if the event stream was already taken.
Sourcepub fn advance(
&self,
increment: &Increment,
) -> QueryResponseFut<Result<(), i32>>
pub fn advance( &self, increment: &Increment, ) -> QueryResponseFut<Result<(), i32>>
Advances the fake clock increment
once.
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.
Sourcepub fn resume_with_increments(
&self,
real: i64,
increment: &Increment,
) -> QueryResponseFut<Result<(), i32>>
pub fn resume_with_increments( &self, real: i64, increment: &Increment, ) -> QueryResponseFut<Result<(), i32>>
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).
Sourcepub fn add_stop_point(
&self,
deadline_id: &DeadlineId,
event_type: DeadlineEventType,
on_stop: EventPair,
) -> QueryResponseFut<Result<(), i32>>
pub fn add_stop_point( &self, deadline_id: &DeadlineId, event_type: DeadlineEventType, on_stop: EventPair, ) -> QueryResponseFut<Result<(), i32>>
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.
Sourcepub fn pause(&self) -> QueryResponseFut<()>
pub fn pause(&self) -> QueryResponseFut<()>
Pauses free-running increments on the fake clock.
Sourcepub fn ignore_named_deadline(
&self,
deadline_id: &DeadlineId,
) -> QueryResponseFut<()>
pub fn ignore_named_deadline( &self, deadline_id: &DeadlineId, ) -> QueryResponseFut<()>
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.