# Clock

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/animation/struct-clock/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct Clock
```

A clock that runs on another clock: its time starts at zero on the first
tick of the parent after it was created, and stands still while it is
paused.

The clock subscribes to its parent when it is created, whether or not
anything is subscribed to it, and unsubscribes on the first tick after
its play state was set to `PlayState::Stop`.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/clock.rs#L14)

## Members

- [`global_clock`](#function-global_clock)
- [`new`](#function-new)
- [`with_parent`](#function-with_parent)

<a id="function-global_clock"></a>

### global_clock

```rust
fn global_clock() -> Rc<dyn IClock>
```

The global clock: the `dyn IGlobalClock` service.

Panics when no global clock is registered.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/clock.rs#L36)

<a id="function-new"></a>

### new

```rust
fn new() -> Rc<Clock>
```

Creates a clock that runs on the global clock.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/clock.rs#L41)

<a id="function-with_parent"></a>

### with_parent

```rust
fn with_parent(parent: &Rc<dyn IClock>) -> Rc<Clock>
```

Creates a clock that runs on `parent`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/animation/clock.rs#L46)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- [`SubscribeGuard<T>`](/docs/0.5.0/api/ferroui-base/reactive/use-subscribeguard/)
- `ErasedDestructor`
- `IntoEither`
- [`IObservable<SignedDuration>`](/docs/0.5.0/api/ferroui-base/reactive/use-iobservable/)
- [`IClock`](/docs/0.5.0/api/ferroui-base/animation/trait-iclock/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
