qr_code_styling/config/
corner_options.rs1use super::{Color, Gradient};
4use crate::types::{CornerSquareType, CornerDotType};
5
6#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct CornersSquareOptions {
10 pub square_type: CornerSquareType,
12 pub color: Color,
14 pub gradient: Option<Gradient>,
16}
17
18impl Default for CornersSquareOptions {
19 fn default() -> Self {
20 Self {
21 square_type: CornerSquareType::Square,
22 color: Color::BLACK,
23 gradient: None,
24 }
25 }
26}
27
28impl CornersSquareOptions {
29 pub fn new(square_type: CornerSquareType) -> Self {
31 Self {
32 square_type,
33 ..Default::default()
34 }
35 }
36
37 pub fn with_type(mut self, square_type: CornerSquareType) -> Self {
39 self.square_type = square_type;
40 self
41 }
42
43 pub fn with_color(mut self, color: Color) -> Self {
45 self.color = color;
46 self
47 }
48
49 pub fn with_gradient(mut self, gradient: Gradient) -> Self {
51 self.gradient = Some(gradient);
52 self
53 }
54}
55
56#[derive(Debug, Clone, PartialEq)]
58#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
59pub struct CornersDotOptions {
60 pub dot_type: CornerDotType,
62 pub color: Color,
64 pub gradient: Option<Gradient>,
66}
67
68impl Default for CornersDotOptions {
69 fn default() -> Self {
70 Self {
71 dot_type: CornerDotType::Dot,
72 color: Color::BLACK,
73 gradient: None,
74 }
75 }
76}
77
78impl CornersDotOptions {
79 pub fn new(dot_type: CornerDotType) -> Self {
81 Self {
82 dot_type,
83 ..Default::default()
84 }
85 }
86
87 pub fn with_type(mut self, dot_type: CornerDotType) -> Self {
89 self.dot_type = dot_type;
90 self
91 }
92
93 pub fn with_color(mut self, color: Color) -> Self {
95 self.color = color;
96 self
97 }
98
99 pub fn with_gradient(mut self, gradient: Gradient) -> Self {
101 self.gradient = Some(gradient);
102 self
103 }
104}