qr_code_styling/config/
qr_options.rs1use crate::types::{ErrorCorrectionLevel, Mode};
4
5#[derive(Debug, Clone, PartialEq)]
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8pub struct QROptions {
9 pub type_number: u8,
11 pub error_correction_level: ErrorCorrectionLevel,
13 pub mode: Option<Mode>,
15}
16
17impl Default for QROptions {
18 fn default() -> Self {
19 Self {
20 type_number: 0, error_correction_level: ErrorCorrectionLevel::Q,
22 mode: None, }
24 }
25}
26
27impl QROptions {
28 pub fn new() -> Self {
30 Self::default()
31 }
32
33 pub fn with_type_number(mut self, type_number: u8) -> Self {
35 self.type_number = type_number.min(40);
36 self
37 }
38
39 pub fn with_error_correction_level(mut self, level: ErrorCorrectionLevel) -> Self {
41 self.error_correction_level = level;
42 self
43 }
44
45 pub fn with_mode(mut self, mode: Mode) -> Self {
47 self.mode = Some(mode);
48 self
49 }
50}