leptos_use_timestamp/
options.rs1use default_struct_builder::DefaultBuilder;
2use std::rc::Rc;
3
4#[derive(DefaultBuilder)]
6pub struct UseTimestampOptions {
7 pub(crate) offset: f64,
9
10 pub(crate) immediate: bool,
12
13 #[builder(into)]
15 pub(crate) interval: TimestampInterval,
16
17 pub(crate) callback: Rc<dyn Fn(f64)>,
19}
20
21#[derive(Copy, Clone, Eq, PartialEq, Debug)]
23pub enum TimestampInterval {
24 RequestAnimationFrame,
26
27 Interval(u64),
29}
30
31impl From<u64> for TimestampInterval {
32 fn from(value: u64) -> Self {
33 Self::Interval(value)
34 }
35}
36
37impl Default for UseTimestampOptions {
38 fn default() -> Self {
39 Self {
40 offset: 0.0,
41 immediate: true,
42 interval: TimestampInterval::RequestAnimationFrame,
43 callback: Rc::new(|_| {}),
44 }
45 }
46}