#[repr(transparent)]
pub struct Timer(_);
Expand description

A Unix signal per-process timer.

Implementations

Creates a new timer based on the clock defined by clockid. The details of the signal and its handler are defined by the passed sigevent.

Set a new alarm on the timer.

Types of alarm

There are 3 types of alarms you can set:

  • one shot: the alarm will trigger once after the specified amount of time. Example: I want an alarm to go off in 60s and then disable itself.

  • interval: the alarm will trigger every specified interval of time. Example: I want an alarm to go off every 60s. The alarm will first go off 60s after I set it and every 60s after that. The alarm will not disable itself.

  • interval delayed: the alarm will trigger after a certain amount of time and then trigger at a specified interval. Example: I want an alarm to go off every 60s but only start in 1h. The alarm will first trigger 1h after I set it and then every 60s after that. The alarm will not disable itself.

Relative vs absolute alarm

If you do not set any TimerSetTimeFlags, then the TimeSpec you pass to the Expiration you want is relative. If however you want an alarm to go off at a certain point in time, you can set TFD_TIMER_ABSTIME. Then the one shot TimeSpec and the delay TimeSpec of the delayed interval are going to be interpreted as absolute.

Disabling alarms

Note: Only one alarm can be set for any given timer. Setting a new alarm actually removes the previous one.

Note: Setting a one shot alarm with a 0s TimeSpec disable the alarm altogether.

Get the parameters for the alarm currently set, if any.

Return the number of timers that have overrun

Each timer is able to queue one signal to the process at a time, meaning if the signal is not handled before the next expiration the timer has ‘overrun’. This function returns how many times that has happened to this timer, up to libc::DELAYTIMER_MAX. If more than the maximum number of overruns have happened the return is capped to the maximum.

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Use this to cast from one trait object type to another. Read more

Use this to upcast a trait to one of its supertraits. Read more

Use this to cast from one trait object type to another. This method is more customizable than the dyn_cast method. Here you can also specify the “source” trait from which the cast is defined. This can for example allow using casts from a supertrait of the current trait object. Read more

Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more