Skip to main content

browser_protocol/animation/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5/// Animation instance.
6
7#[derive(Debug, Clone, Serialize, Deserialize, Default)]
8#[serde(rename_all = "camelCase")]
9pub struct Animation<'a> {
10    /// 'Animation''s id.
11    id: Cow<'a, str>,
12    /// 'Animation''s name.
13    name: Cow<'a, str>,
14    /// 'Animation''s internal paused state.
15    pausedState: bool,
16    /// 'Animation''s play state.
17    playState: Cow<'a, str>,
18    /// 'Animation''s playback rate.
19    playbackRate: f64,
20    /// 'Animation''s start time.
21    /// Milliseconds for time based animations and
22    /// percentage [0 - 100] for scroll driven animations
23    /// (i.e. when viewOrScrollTimeline exists).
24    startTime: f64,
25    /// 'Animation''s current time.
26    currentTime: f64,
27    /// Animation type of 'Animation'.
28    #[serde(rename = "type")]
29    type_: Cow<'a, str>,
30    /// 'Animation''s source animation node.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    source: Option<AnimationEffect<'a>>,
33    /// A unique ID for 'Animation' representing the sources that triggered this CSS
34    /// animation/transition.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    cssId: Option<Cow<'a, str>>,
37    /// View or scroll timeline
38    #[serde(skip_serializing_if = "Option::is_none")]
39    viewOrScrollTimeline: Option<ViewOrScrollTimeline>,
40}
41
42impl<'a> Animation<'a> {
43    pub fn builder(id: impl Into<Cow<'a, str>>, name: impl Into<Cow<'a, str>>, pausedState: bool, playState: impl Into<Cow<'a, str>>, playbackRate: f64, startTime: f64, currentTime: f64, type_: impl Into<Cow<'a, str>>) -> AnimationBuilder<'a> {
44        AnimationBuilder {
45            id: id.into(),
46            name: name.into(),
47            pausedState: pausedState,
48            playState: playState.into(),
49            playbackRate: playbackRate,
50            startTime: startTime,
51            currentTime: currentTime,
52            type_: type_.into(),
53            source: None,
54            cssId: None,
55            viewOrScrollTimeline: None,
56        }
57    }
58    pub fn id(&self) -> &str { self.id.as_ref() }
59    pub fn name(&self) -> &str { self.name.as_ref() }
60    pub fn pausedState(&self) -> bool { self.pausedState }
61    pub fn playState(&self) -> &str { self.playState.as_ref() }
62    pub fn playbackRate(&self) -> f64 { self.playbackRate }
63    pub fn startTime(&self) -> f64 { self.startTime }
64    pub fn currentTime(&self) -> f64 { self.currentTime }
65    pub fn type_(&self) -> &str { self.type_.as_ref() }
66    pub fn source(&self) -> Option<&AnimationEffect<'a>> { self.source.as_ref() }
67    pub fn cssId(&self) -> Option<&str> { self.cssId.as_deref() }
68    pub fn viewOrScrollTimeline(&self) -> Option<&ViewOrScrollTimeline> { self.viewOrScrollTimeline.as_ref() }
69}
70
71
72pub struct AnimationBuilder<'a> {
73    id: Cow<'a, str>,
74    name: Cow<'a, str>,
75    pausedState: bool,
76    playState: Cow<'a, str>,
77    playbackRate: f64,
78    startTime: f64,
79    currentTime: f64,
80    type_: Cow<'a, str>,
81    source: Option<AnimationEffect<'a>>,
82    cssId: Option<Cow<'a, str>>,
83    viewOrScrollTimeline: Option<ViewOrScrollTimeline>,
84}
85
86impl<'a> AnimationBuilder<'a> {
87    /// 'Animation''s source animation node.
88    pub fn source(mut self, source: AnimationEffect<'a>) -> Self { self.source = Some(source); self }
89    /// A unique ID for 'Animation' representing the sources that triggered this CSS
90    /// animation/transition.
91    pub fn cssId(mut self, cssId: impl Into<Cow<'a, str>>) -> Self { self.cssId = Some(cssId.into()); self }
92    /// View or scroll timeline
93    pub fn viewOrScrollTimeline(mut self, viewOrScrollTimeline: ViewOrScrollTimeline) -> Self { self.viewOrScrollTimeline = Some(viewOrScrollTimeline); self }
94    pub fn build(self) -> Animation<'a> {
95        Animation {
96            id: self.id,
97            name: self.name,
98            pausedState: self.pausedState,
99            playState: self.playState,
100            playbackRate: self.playbackRate,
101            startTime: self.startTime,
102            currentTime: self.currentTime,
103            type_: self.type_,
104            source: self.source,
105            cssId: self.cssId,
106            viewOrScrollTimeline: self.viewOrScrollTimeline,
107        }
108    }
109}
110
111/// Timeline instance
112
113#[derive(Debug, Clone, Serialize, Deserialize, Default)]
114#[serde(rename_all = "camelCase")]
115pub struct ViewOrScrollTimeline {
116    /// Scroll container node
117    #[serde(skip_serializing_if = "Option::is_none")]
118    sourceNodeId: Option<crate::dom::BackendNodeId>,
119    /// Represents the starting scroll position of the timeline
120    /// as a length offset in pixels from scroll origin.
121    #[serde(skip_serializing_if = "Option::is_none")]
122    startOffset: Option<f64>,
123    /// Represents the ending scroll position of the timeline
124    /// as a length offset in pixels from scroll origin.
125    #[serde(skip_serializing_if = "Option::is_none")]
126    endOffset: Option<f64>,
127    /// The element whose principal box's visibility in the
128    /// scrollport defined the progress of the timeline.
129    /// Does not exist for animations with ScrollTimeline
130    #[serde(skip_serializing_if = "Option::is_none")]
131    subjectNodeId: Option<crate::dom::BackendNodeId>,
132    /// Orientation of the scroll
133    axis: crate::dom::ScrollOrientation,
134}
135
136impl ViewOrScrollTimeline {
137    pub fn builder(axis: crate::dom::ScrollOrientation) -> ViewOrScrollTimelineBuilder {
138        ViewOrScrollTimelineBuilder {
139            sourceNodeId: None,
140            startOffset: None,
141            endOffset: None,
142            subjectNodeId: None,
143            axis: axis,
144        }
145    }
146    pub fn sourceNodeId(&self) -> Option<&crate::dom::BackendNodeId> { self.sourceNodeId.as_ref() }
147    pub fn startOffset(&self) -> Option<f64> { self.startOffset }
148    pub fn endOffset(&self) -> Option<f64> { self.endOffset }
149    pub fn subjectNodeId(&self) -> Option<&crate::dom::BackendNodeId> { self.subjectNodeId.as_ref() }
150    pub fn axis(&self) -> &crate::dom::ScrollOrientation { &self.axis }
151}
152
153
154pub struct ViewOrScrollTimelineBuilder {
155    sourceNodeId: Option<crate::dom::BackendNodeId>,
156    startOffset: Option<f64>,
157    endOffset: Option<f64>,
158    subjectNodeId: Option<crate::dom::BackendNodeId>,
159    axis: crate::dom::ScrollOrientation,
160}
161
162impl ViewOrScrollTimelineBuilder {
163    /// Scroll container node
164    pub fn sourceNodeId(mut self, sourceNodeId: crate::dom::BackendNodeId) -> Self { self.sourceNodeId = Some(sourceNodeId); self }
165    /// Represents the starting scroll position of the timeline
166    /// as a length offset in pixels from scroll origin.
167    pub fn startOffset(mut self, startOffset: f64) -> Self { self.startOffset = Some(startOffset); self }
168    /// Represents the ending scroll position of the timeline
169    /// as a length offset in pixels from scroll origin.
170    pub fn endOffset(mut self, endOffset: f64) -> Self { self.endOffset = Some(endOffset); self }
171    /// The element whose principal box's visibility in the
172    /// scrollport defined the progress of the timeline.
173    /// Does not exist for animations with ScrollTimeline
174    pub fn subjectNodeId(mut self, subjectNodeId: crate::dom::BackendNodeId) -> Self { self.subjectNodeId = Some(subjectNodeId); self }
175    pub fn build(self) -> ViewOrScrollTimeline {
176        ViewOrScrollTimeline {
177            sourceNodeId: self.sourceNodeId,
178            startOffset: self.startOffset,
179            endOffset: self.endOffset,
180            subjectNodeId: self.subjectNodeId,
181            axis: self.axis,
182        }
183    }
184}
185
186/// AnimationEffect instance
187
188#[derive(Debug, Clone, Serialize, Deserialize, Default)]
189#[serde(rename_all = "camelCase")]
190pub struct AnimationEffect<'a> {
191    /// 'AnimationEffect''s delay.
192    delay: f64,
193    /// 'AnimationEffect''s end delay.
194    endDelay: f64,
195    /// 'AnimationEffect''s iteration start.
196    iterationStart: f64,
197    /// 'AnimationEffect''s iterations. Omitted if the value is infinite.
198    #[serde(skip_serializing_if = "Option::is_none")]
199    iterations: Option<f64>,
200    /// 'AnimationEffect''s iteration duration.
201    /// Milliseconds for time based animations and
202    /// percentage [0 - 100] for scroll driven animations
203    /// (i.e. when viewOrScrollTimeline exists).
204    duration: f64,
205    /// 'AnimationEffect''s playback direction.
206    direction: Cow<'a, str>,
207    /// 'AnimationEffect''s fill mode.
208    fill: Cow<'a, str>,
209    /// 'AnimationEffect''s target node.
210    #[serde(skip_serializing_if = "Option::is_none")]
211    backendNodeId: Option<crate::dom::BackendNodeId>,
212    /// 'AnimationEffect''s keyframes.
213    #[serde(skip_serializing_if = "Option::is_none")]
214    keyframesRule: Option<KeyframesRule<'a>>,
215    /// 'AnimationEffect''s timing function.
216    easing: Cow<'a, str>,
217}
218
219impl<'a> AnimationEffect<'a> {
220    pub fn builder(delay: f64, endDelay: f64, iterationStart: f64, duration: f64, direction: impl Into<Cow<'a, str>>, fill: impl Into<Cow<'a, str>>, easing: impl Into<Cow<'a, str>>) -> AnimationEffectBuilder<'a> {
221        AnimationEffectBuilder {
222            delay: delay,
223            endDelay: endDelay,
224            iterationStart: iterationStart,
225            iterations: None,
226            duration: duration,
227            direction: direction.into(),
228            fill: fill.into(),
229            backendNodeId: None,
230            keyframesRule: None,
231            easing: easing.into(),
232        }
233    }
234    pub fn delay(&self) -> f64 { self.delay }
235    pub fn endDelay(&self) -> f64 { self.endDelay }
236    pub fn iterationStart(&self) -> f64 { self.iterationStart }
237    pub fn iterations(&self) -> Option<f64> { self.iterations }
238    pub fn duration(&self) -> f64 { self.duration }
239    pub fn direction(&self) -> &str { self.direction.as_ref() }
240    pub fn fill(&self) -> &str { self.fill.as_ref() }
241    pub fn backendNodeId(&self) -> Option<&crate::dom::BackendNodeId> { self.backendNodeId.as_ref() }
242    pub fn keyframesRule(&self) -> Option<&KeyframesRule<'a>> { self.keyframesRule.as_ref() }
243    pub fn easing(&self) -> &str { self.easing.as_ref() }
244}
245
246
247pub struct AnimationEffectBuilder<'a> {
248    delay: f64,
249    endDelay: f64,
250    iterationStart: f64,
251    iterations: Option<f64>,
252    duration: f64,
253    direction: Cow<'a, str>,
254    fill: Cow<'a, str>,
255    backendNodeId: Option<crate::dom::BackendNodeId>,
256    keyframesRule: Option<KeyframesRule<'a>>,
257    easing: Cow<'a, str>,
258}
259
260impl<'a> AnimationEffectBuilder<'a> {
261    /// 'AnimationEffect''s iterations. Omitted if the value is infinite.
262    pub fn iterations(mut self, iterations: f64) -> Self { self.iterations = Some(iterations); self }
263    /// 'AnimationEffect''s target node.
264    pub fn backendNodeId(mut self, backendNodeId: crate::dom::BackendNodeId) -> Self { self.backendNodeId = Some(backendNodeId); self }
265    /// 'AnimationEffect''s keyframes.
266    pub fn keyframesRule(mut self, keyframesRule: KeyframesRule<'a>) -> Self { self.keyframesRule = Some(keyframesRule); self }
267    pub fn build(self) -> AnimationEffect<'a> {
268        AnimationEffect {
269            delay: self.delay,
270            endDelay: self.endDelay,
271            iterationStart: self.iterationStart,
272            iterations: self.iterations,
273            duration: self.duration,
274            direction: self.direction,
275            fill: self.fill,
276            backendNodeId: self.backendNodeId,
277            keyframesRule: self.keyframesRule,
278            easing: self.easing,
279        }
280    }
281}
282
283/// Keyframes Rule
284
285#[derive(Debug, Clone, Serialize, Deserialize, Default)]
286#[serde(rename_all = "camelCase")]
287pub struct KeyframesRule<'a> {
288    /// CSS keyframed animation's name.
289    #[serde(skip_serializing_if = "Option::is_none")]
290    name: Option<Cow<'a, str>>,
291    /// List of animation keyframes.
292    keyframes: Vec<KeyframeStyle<'a>>,
293}
294
295impl<'a> KeyframesRule<'a> {
296    pub fn builder(keyframes: Vec<KeyframeStyle<'a>>) -> KeyframesRuleBuilder<'a> {
297        KeyframesRuleBuilder {
298            name: None,
299            keyframes: keyframes,
300        }
301    }
302    pub fn name(&self) -> Option<&str> { self.name.as_deref() }
303    pub fn keyframes(&self) -> &[KeyframeStyle<'a>] { &self.keyframes }
304}
305
306
307pub struct KeyframesRuleBuilder<'a> {
308    name: Option<Cow<'a, str>>,
309    keyframes: Vec<KeyframeStyle<'a>>,
310}
311
312impl<'a> KeyframesRuleBuilder<'a> {
313    /// CSS keyframed animation's name.
314    pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self { self.name = Some(name.into()); self }
315    pub fn build(self) -> KeyframesRule<'a> {
316        KeyframesRule {
317            name: self.name,
318            keyframes: self.keyframes,
319        }
320    }
321}
322
323/// Keyframe Style
324
325#[derive(Debug, Clone, Serialize, Deserialize, Default)]
326#[serde(rename_all = "camelCase")]
327pub struct KeyframeStyle<'a> {
328    /// Keyframe's time offset.
329    offset: Cow<'a, str>,
330    /// 'AnimationEffect''s timing function.
331    easing: Cow<'a, str>,
332}
333
334impl<'a> KeyframeStyle<'a> {
335    pub fn builder(offset: impl Into<Cow<'a, str>>, easing: impl Into<Cow<'a, str>>) -> KeyframeStyleBuilder<'a> {
336        KeyframeStyleBuilder {
337            offset: offset.into(),
338            easing: easing.into(),
339        }
340    }
341    pub fn offset(&self) -> &str { self.offset.as_ref() }
342    pub fn easing(&self) -> &str { self.easing.as_ref() }
343}
344
345
346pub struct KeyframeStyleBuilder<'a> {
347    offset: Cow<'a, str>,
348    easing: Cow<'a, str>,
349}
350
351impl<'a> KeyframeStyleBuilder<'a> {
352    pub fn build(self) -> KeyframeStyle<'a> {
353        KeyframeStyle {
354            offset: self.offset,
355            easing: self.easing,
356        }
357    }
358}
359
360#[derive(Debug, Clone, Serialize, Deserialize, Default)]
361pub struct DisableParams {}
362
363impl DisableParams { pub const METHOD: &'static str = "Animation.disable"; }
364
365impl<'a> crate::CdpCommand<'a> for DisableParams {
366    const METHOD: &'static str = "Animation.disable";
367    type Response = crate::EmptyReturns;
368}
369
370#[derive(Debug, Clone, Serialize, Deserialize, Default)]
371pub struct EnableParams {}
372
373impl EnableParams { pub const METHOD: &'static str = "Animation.enable"; }
374
375impl<'a> crate::CdpCommand<'a> for EnableParams {
376    const METHOD: &'static str = "Animation.enable";
377    type Response = crate::EmptyReturns;
378}
379
380/// Returns the current time of the an animation.
381
382#[derive(Debug, Clone, Serialize, Deserialize, Default)]
383#[serde(rename_all = "camelCase")]
384pub struct GetCurrentTimeParams<'a> {
385    /// Id of animation.
386    id: Cow<'a, str>,
387}
388
389impl<'a> GetCurrentTimeParams<'a> {
390    pub fn builder(id: impl Into<Cow<'a, str>>) -> GetCurrentTimeParamsBuilder<'a> {
391        GetCurrentTimeParamsBuilder {
392            id: id.into(),
393        }
394    }
395    pub fn id(&self) -> &str { self.id.as_ref() }
396}
397
398
399pub struct GetCurrentTimeParamsBuilder<'a> {
400    id: Cow<'a, str>,
401}
402
403impl<'a> GetCurrentTimeParamsBuilder<'a> {
404    pub fn build(self) -> GetCurrentTimeParams<'a> {
405        GetCurrentTimeParams {
406            id: self.id,
407        }
408    }
409}
410
411/// Returns the current time of the an animation.
412
413#[derive(Debug, Clone, Serialize, Deserialize, Default)]
414#[serde(rename_all = "camelCase")]
415pub struct GetCurrentTimeReturns {
416    /// Current time of the page.
417    currentTime: f64,
418}
419
420impl GetCurrentTimeReturns {
421    pub fn builder(currentTime: f64) -> GetCurrentTimeReturnsBuilder {
422        GetCurrentTimeReturnsBuilder {
423            currentTime: currentTime,
424        }
425    }
426    pub fn currentTime(&self) -> f64 { self.currentTime }
427}
428
429
430pub struct GetCurrentTimeReturnsBuilder {
431    currentTime: f64,
432}
433
434impl GetCurrentTimeReturnsBuilder {
435    pub fn build(self) -> GetCurrentTimeReturns {
436        GetCurrentTimeReturns {
437            currentTime: self.currentTime,
438        }
439    }
440}
441
442impl<'a> GetCurrentTimeParams<'a> { pub const METHOD: &'static str = "Animation.getCurrentTime"; }
443
444impl<'a> crate::CdpCommand<'a> for GetCurrentTimeParams<'a> {
445    const METHOD: &'static str = "Animation.getCurrentTime";
446    type Response = GetCurrentTimeReturns;
447}
448
449/// Gets the playback rate of the document timeline.
450
451#[derive(Debug, Clone, Serialize, Deserialize, Default)]
452#[serde(rename_all = "camelCase")]
453pub struct GetPlaybackRateReturns {
454    /// Playback rate for animations on page.
455    playbackRate: f64,
456}
457
458impl GetPlaybackRateReturns {
459    pub fn builder(playbackRate: f64) -> GetPlaybackRateReturnsBuilder {
460        GetPlaybackRateReturnsBuilder {
461            playbackRate: playbackRate,
462        }
463    }
464    pub fn playbackRate(&self) -> f64 { self.playbackRate }
465}
466
467
468pub struct GetPlaybackRateReturnsBuilder {
469    playbackRate: f64,
470}
471
472impl GetPlaybackRateReturnsBuilder {
473    pub fn build(self) -> GetPlaybackRateReturns {
474        GetPlaybackRateReturns {
475            playbackRate: self.playbackRate,
476        }
477    }
478}
479
480#[derive(Debug, Clone, Serialize, Deserialize, Default)]
481pub struct GetPlaybackRateParams {}
482
483impl GetPlaybackRateParams { pub const METHOD: &'static str = "Animation.getPlaybackRate"; }
484
485impl<'a> crate::CdpCommand<'a> for GetPlaybackRateParams {
486    const METHOD: &'static str = "Animation.getPlaybackRate";
487    type Response = GetPlaybackRateReturns;
488}
489
490/// Releases a set of animations to no longer be manipulated.
491
492#[derive(Debug, Clone, Serialize, Deserialize, Default)]
493#[serde(rename_all = "camelCase")]
494pub struct ReleaseAnimationsParams<'a> {
495    /// List of animation ids to seek.
496    animations: Vec<Cow<'a, str>>,
497}
498
499impl<'a> ReleaseAnimationsParams<'a> {
500    pub fn builder(animations: Vec<Cow<'a, str>>) -> ReleaseAnimationsParamsBuilder<'a> {
501        ReleaseAnimationsParamsBuilder {
502            animations: animations,
503        }
504    }
505    pub fn animations(&self) -> &[Cow<'a, str>] { &self.animations }
506}
507
508
509pub struct ReleaseAnimationsParamsBuilder<'a> {
510    animations: Vec<Cow<'a, str>>,
511}
512
513impl<'a> ReleaseAnimationsParamsBuilder<'a> {
514    pub fn build(self) -> ReleaseAnimationsParams<'a> {
515        ReleaseAnimationsParams {
516            animations: self.animations,
517        }
518    }
519}
520
521impl<'a> ReleaseAnimationsParams<'a> { pub const METHOD: &'static str = "Animation.releaseAnimations"; }
522
523impl<'a> crate::CdpCommand<'a> for ReleaseAnimationsParams<'a> {
524    const METHOD: &'static str = "Animation.releaseAnimations";
525    type Response = crate::EmptyReturns;
526}
527
528/// Gets the remote object of the Animation.
529
530#[derive(Debug, Clone, Serialize, Deserialize, Default)]
531#[serde(rename_all = "camelCase")]
532pub struct ResolveAnimationParams<'a> {
533    /// Animation id.
534    animationId: Cow<'a, str>,
535}
536
537impl<'a> ResolveAnimationParams<'a> {
538    pub fn builder(animationId: impl Into<Cow<'a, str>>) -> ResolveAnimationParamsBuilder<'a> {
539        ResolveAnimationParamsBuilder {
540            animationId: animationId.into(),
541        }
542    }
543    pub fn animationId(&self) -> &str { self.animationId.as_ref() }
544}
545
546
547pub struct ResolveAnimationParamsBuilder<'a> {
548    animationId: Cow<'a, str>,
549}
550
551impl<'a> ResolveAnimationParamsBuilder<'a> {
552    pub fn build(self) -> ResolveAnimationParams<'a> {
553        ResolveAnimationParams {
554            animationId: self.animationId,
555        }
556    }
557}
558
559/// Gets the remote object of the Animation.
560
561#[derive(Debug, Clone, Serialize, Deserialize, Default)]
562#[serde(rename_all = "camelCase")]
563pub struct ResolveAnimationReturns {
564    /// Corresponding remote object.
565    remoteObject: crate::runtime::RemoteObject,
566}
567
568impl ResolveAnimationReturns {
569    pub fn builder(remoteObject: crate::runtime::RemoteObject) -> ResolveAnimationReturnsBuilder {
570        ResolveAnimationReturnsBuilder {
571            remoteObject: remoteObject,
572        }
573    }
574    pub fn remoteObject(&self) -> &crate::runtime::RemoteObject { &self.remoteObject }
575}
576
577
578pub struct ResolveAnimationReturnsBuilder {
579    remoteObject: crate::runtime::RemoteObject,
580}
581
582impl ResolveAnimationReturnsBuilder {
583    pub fn build(self) -> ResolveAnimationReturns {
584        ResolveAnimationReturns {
585            remoteObject: self.remoteObject,
586        }
587    }
588}
589
590impl<'a> ResolveAnimationParams<'a> { pub const METHOD: &'static str = "Animation.resolveAnimation"; }
591
592impl<'a> crate::CdpCommand<'a> for ResolveAnimationParams<'a> {
593    const METHOD: &'static str = "Animation.resolveAnimation";
594    type Response = ResolveAnimationReturns;
595}
596
597/// Seek a set of animations to a particular time within each animation.
598
599#[derive(Debug, Clone, Serialize, Deserialize, Default)]
600#[serde(rename_all = "camelCase")]
601pub struct SeekAnimationsParams<'a> {
602    /// List of animation ids to seek.
603    animations: Vec<Cow<'a, str>>,
604    /// Set the current time of each animation.
605    currentTime: f64,
606}
607
608impl<'a> SeekAnimationsParams<'a> {
609    pub fn builder(animations: Vec<Cow<'a, str>>, currentTime: f64) -> SeekAnimationsParamsBuilder<'a> {
610        SeekAnimationsParamsBuilder {
611            animations: animations,
612            currentTime: currentTime,
613        }
614    }
615    pub fn animations(&self) -> &[Cow<'a, str>] { &self.animations }
616    pub fn currentTime(&self) -> f64 { self.currentTime }
617}
618
619
620pub struct SeekAnimationsParamsBuilder<'a> {
621    animations: Vec<Cow<'a, str>>,
622    currentTime: f64,
623}
624
625impl<'a> SeekAnimationsParamsBuilder<'a> {
626    pub fn build(self) -> SeekAnimationsParams<'a> {
627        SeekAnimationsParams {
628            animations: self.animations,
629            currentTime: self.currentTime,
630        }
631    }
632}
633
634impl<'a> SeekAnimationsParams<'a> { pub const METHOD: &'static str = "Animation.seekAnimations"; }
635
636impl<'a> crate::CdpCommand<'a> for SeekAnimationsParams<'a> {
637    const METHOD: &'static str = "Animation.seekAnimations";
638    type Response = crate::EmptyReturns;
639}
640
641/// Sets the paused state of a set of animations.
642
643#[derive(Debug, Clone, Serialize, Deserialize, Default)]
644#[serde(rename_all = "camelCase")]
645pub struct SetPausedParams<'a> {
646    /// Animations to set the pause state of.
647    animations: Vec<Cow<'a, str>>,
648    /// Paused state to set to.
649    paused: bool,
650}
651
652impl<'a> SetPausedParams<'a> {
653    pub fn builder(animations: Vec<Cow<'a, str>>, paused: bool) -> SetPausedParamsBuilder<'a> {
654        SetPausedParamsBuilder {
655            animations: animations,
656            paused: paused,
657        }
658    }
659    pub fn animations(&self) -> &[Cow<'a, str>] { &self.animations }
660    pub fn paused(&self) -> bool { self.paused }
661}
662
663
664pub struct SetPausedParamsBuilder<'a> {
665    animations: Vec<Cow<'a, str>>,
666    paused: bool,
667}
668
669impl<'a> SetPausedParamsBuilder<'a> {
670    pub fn build(self) -> SetPausedParams<'a> {
671        SetPausedParams {
672            animations: self.animations,
673            paused: self.paused,
674        }
675    }
676}
677
678impl<'a> SetPausedParams<'a> { pub const METHOD: &'static str = "Animation.setPaused"; }
679
680impl<'a> crate::CdpCommand<'a> for SetPausedParams<'a> {
681    const METHOD: &'static str = "Animation.setPaused";
682    type Response = crate::EmptyReturns;
683}
684
685/// Sets the playback rate of the document timeline.
686
687#[derive(Debug, Clone, Serialize, Deserialize, Default)]
688#[serde(rename_all = "camelCase")]
689pub struct SetPlaybackRateParams {
690    /// Playback rate for animations on page
691    playbackRate: f64,
692}
693
694impl SetPlaybackRateParams {
695    pub fn builder(playbackRate: f64) -> SetPlaybackRateParamsBuilder {
696        SetPlaybackRateParamsBuilder {
697            playbackRate: playbackRate,
698        }
699    }
700    pub fn playbackRate(&self) -> f64 { self.playbackRate }
701}
702
703
704pub struct SetPlaybackRateParamsBuilder {
705    playbackRate: f64,
706}
707
708impl SetPlaybackRateParamsBuilder {
709    pub fn build(self) -> SetPlaybackRateParams {
710        SetPlaybackRateParams {
711            playbackRate: self.playbackRate,
712        }
713    }
714}
715
716impl SetPlaybackRateParams { pub const METHOD: &'static str = "Animation.setPlaybackRate"; }
717
718impl<'a> crate::CdpCommand<'a> for SetPlaybackRateParams {
719    const METHOD: &'static str = "Animation.setPlaybackRate";
720    type Response = crate::EmptyReturns;
721}
722
723/// Sets the timing of an animation node.
724
725#[derive(Debug, Clone, Serialize, Deserialize, Default)]
726#[serde(rename_all = "camelCase")]
727pub struct SetTimingParams<'a> {
728    /// Animation id.
729    animationId: Cow<'a, str>,
730    /// Duration of the animation.
731    duration: f64,
732    /// Delay of the animation.
733    delay: f64,
734}
735
736impl<'a> SetTimingParams<'a> {
737    pub fn builder(animationId: impl Into<Cow<'a, str>>, duration: f64, delay: f64) -> SetTimingParamsBuilder<'a> {
738        SetTimingParamsBuilder {
739            animationId: animationId.into(),
740            duration: duration,
741            delay: delay,
742        }
743    }
744    pub fn animationId(&self) -> &str { self.animationId.as_ref() }
745    pub fn duration(&self) -> f64 { self.duration }
746    pub fn delay(&self) -> f64 { self.delay }
747}
748
749
750pub struct SetTimingParamsBuilder<'a> {
751    animationId: Cow<'a, str>,
752    duration: f64,
753    delay: f64,
754}
755
756impl<'a> SetTimingParamsBuilder<'a> {
757    pub fn build(self) -> SetTimingParams<'a> {
758        SetTimingParams {
759            animationId: self.animationId,
760            duration: self.duration,
761            delay: self.delay,
762        }
763    }
764}
765
766impl<'a> SetTimingParams<'a> { pub const METHOD: &'static str = "Animation.setTiming"; }
767
768impl<'a> crate::CdpCommand<'a> for SetTimingParams<'a> {
769    const METHOD: &'static str = "Animation.setTiming";
770    type Response = crate::EmptyReturns;
771}