1use crate::Unit;
2
3pub trait Spacing: Default {
4 type Unit: Unit + Clone;
5 fn left(self, value: impl Into<Self::Unit>) -> Self;
6 fn right(self, value: impl Into<Self::Unit>) -> Self;
7 fn top(self, value: impl Into<Self::Unit>) -> Self;
8 fn bottom(self, value: impl Into<Self::Unit>) -> Self;
9
10 fn x(self, value: impl Into<Self::Unit>) -> Self {
11 let value = value.into();
12 self.left(value.clone()).right(value)
13 }
14
15 fn y(self, value: impl Into<Self::Unit>) -> Self {
16 let value = value.into();
17 self.top(value.clone()).bottom(value)
18 }
19
20 fn horizontal(self, value: impl Into<Self::Unit>) -> Self {
21 self.y(value)
22 }
23
24 fn vertical(self, value: impl Into<Self::Unit>) -> Self {
25 self.x(value)
26 }
27
28 fn all(self, value: impl Into<Self::Unit>) -> Self {
29 let value = value.into();
30 self.x(value.clone()).y(value)
31 }
32
33 fn zero(self) -> Self {
34 Self::default().all(Self::Unit::zero())
35 }
36
37 fn half(self) -> Self {
38 Self::default().all(Self::Unit::half())
39 }
40
41 fn full(self) -> Self {
42 Self::default().all(Self::Unit::full())
43 }
44}