aura_anim_iced/behavior/
rule.rs1use crate::{
2 AnimationTargetId, PropertyTransition, Timing,
3 behavior::TransitionValueKind,
4 property::{PropertySpec, PropertyValueKind},
5};
6
7#[derive(Debug, Clone, Copy, PartialEq)]
12pub struct BehaviorRule<K: PropertyValueKind> {
13 property: PropertySpec<K>,
14 timing: Timing,
15}
16
17impl<K: PropertyValueKind> BehaviorRule<K> {
18 #[must_use]
20 pub fn new(property: PropertySpec<K>) -> Self {
21 Self {
22 property,
23 timing: Timing::default(),
24 }
25 }
26
27 #[must_use]
29 pub const fn with_timing(mut self, timing: Timing) -> Self {
30 self.timing = timing;
31 self
32 }
33
34 #[must_use]
36 pub const fn property(&self) -> PropertySpec<K> {
37 self.property
38 }
39
40 #[must_use]
42 pub const fn timing(&self) -> Timing {
43 self.timing
44 }
45
46 #[must_use]
48 pub fn bind(self, target: AnimationTargetId) -> PropertyTransition<K>
49 where
50 K: TransitionValueKind,
51 K::Inner: Copy + PartialEq,
52 {
53 PropertyTransition::from_rule(target, &self)
54 }
55}