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