Debian Codegraph @

src/convert/mod.rs

raw symbols SCIP
1 //! Converts a [`crate::QRCode`] to image or SVG you will need to activate associated feature flag
2
3 #[cfg(feature = "svg")]
4 #[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
5 pub mod svgrust-analyzer cargo fast_qr 0.13.1 convert/svg/;
6 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#;
7
8 #[cfg(feature = "svg")]
9 use svgrust-analyzer cargo fast_qr 0.13.1 convert/svg/::SvgErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#;
10
11 #[cfg(feature = "image")]
12 #[cfg_attr(docsrs, doc(cfg(feature = "image")))]
13 pub mod imagerust-analyzer cargo fast_qr 0.13.1 convert/image/;
14 #[cfg(feature = "image")]
15 use imagerust-analyzer cargo fast_qr 0.13.1 convert/image/::ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#;
16
17 use craterust-analyzer cargo fast_qr 0.13.1 crate/::Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#;
18
19 /// Converts a position to a module svg
20 /// # Example
21 ///
22 /// For the square shape, the svg is `M{x},{y}h1v1h-1`
23 ///
24 /// ```rust
25 /// # use fast_qr::Module;
26 /// fn square(y: usize, x: usize, _module: Module) -> String {
27 /// format!("M{x},{y}h1v1h-1")
28 /// }
29 /// ```
30 pub type ModuleFunctionrust-analyzer cargo fast_qr 0.13.1 convert/ModuleFunction# = fn(usize, usize, Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#;
31
32 #[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))]
33 use wasm_bindgen::prelude::*;
34
35 /// Different possible Shapes to represent modules in a [`crate::QRCode`]
36 #[repr(C)]
37 #[wasm_bindgen]
38 #[cfg(feature = "wasm-bindgen")]
39 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
40 pub enum Shape {
41 /// Square Shape
42 Square,
43 /// Circle Shape
44 Circle,
45 /// RoundedSquare Shape
46 RoundedSquare,
47 /// Vertical Shape
48 Vertical,
49 /// Horizontal Shape
50 Horizontal,
51 /// Diamond Shape
52 Diamond,
53 }
54
55 /// Different possible Shapes to represent modules in a [`crate::QRCode`]
56 #[cfg(not(feature = "wasm-bindgen"))]
57 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
58 pub enum Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape# {
59 /// Square Shape
60 Squarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Square#,
61 /// Circle Shape
62 Circlerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Circle#,
63 /// RoundedSquare Shape
64 RoundedSquarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#RoundedSquare#,
65 /// Vertical Shape
66 Verticalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Vertical#,
67 /// Horizontal Shape
68 Horizontalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Horizontal#,
69 /// Diamond Shape
70 Diamondrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Diamond#,
71 /// Custom Shape with a function / closure
72 /// # Example
73 /// ```rust
74 /// use fast_qr::convert::Shape;
75 /// let command_function = |y, x, cell| {
76 /// if x % 2 == 0 {
77 /// // Works thanks to Deref
78 /// Shape::Square(y, x, cell)
79 /// } else {
80 /// // Rectangle
81 /// format!("M{x},{y}h1v.5h-1")
82 /// }
83 /// };
84 /// let command = Shape::Command(command_function);
85 /// ```
86 ///
87 /// <svg viewBox="0 0 37 37" xmlns="http://www.w3.org/2000/svg" width="250px">
88 /// <rect width="37px" height="37px" fill="#ffffff" />
89 /// <path
90 /// d="M4,4h1v1h-1M4,5h1v1h-1M4,6h1v1h-1M4,7h1v1h-1M4,8h1v1h-1M4,9h1v1h-1M4,10h1v1h-1M4,12h1v1h-1M4,13h1v1h-1M4,17h1v1h-1M4,19h1v1h-1M4,22h1v1h-1M4,24h1v1h-1M4,26h1v1h-1M4,27h1v1h-1M4,28h1v1h-1M4,29h1v1h-1M4,30h1v1h-1M4,31h1v1h-1M4,32h1v1h-1M5,4h1v.5h-1M5,10h1v.5h-1M5,12h1v.5h-1M5,13h1v.5h-1M5,14h1v.5h-1M5,17h1v.5h-1M5,19h1v.5h-1M5,22h1v.5h-1M5,23h1v.5h-1M5,26h1v.5h-1M5,32h1v.5h-1M6,4h1v1h-1M6,6h1v1h-1M6,7h1v1h-1M6,8h1v1h-1M6,10h1v1h-1M6,12h1v1h-1M6,14h1v1h-1M6,16h1v1h-1M6,18h1v1h-1M6,19h1v1h-1M6,23h1v1h-1M6,24h1v1h-1M6,26h1v1h-1M6,28h1v1h-1M6,29h1v1h-1M6,30h1v1h-1M6,32h1v1h-1M7,4h1v.5h-1M7,6h1v.5h-1M7,7h1v.5h-1M7,8h1v.5h-1M7,10h1v.5h-1M7,13h1v.5h-1M7,15h1v.5h-1M7,18h1v.5h-1M7,21h1v.5h-1M7,23h1v.5h-1M7,26h1v.5h-1M7,28h1v.5h-1M7,29h1v.5h-1M7,30h1v.5h-1M7,32h1v.5h-1M8,4h1v1h-1M8,6h1v1h-1M8,7h1v1h-1M8,8h1v1h-1M8,10h1v1h-1M8,16h1v1h-1M8,17h1v1h-1M8,18h1v1h-1M8,19h1v1h-1M8,20h1v1h-1M8,22h1v1h-1M8,23h1v1h-1M8,24h1v1h-1M8,26h1v1h-1M8,28h1v1h-1M8,29h1v1h-1M8,30h1v1h-1M8,32h1v1h-1M9,4h1v.5h-1M9,10h1v.5h-1M9,12h1v.5h-1M9,13h1v.5h-1M9,14h1v.5h-1M9,15h1v.5h-1M9,16h1v.5h-1M9,19h1v.5h-1M9,22h1v.5h-1M9,26h1v.5h-1M9,32h1v.5h-1M10,4h1v1h-1M10,5h1v1h-1M10,6h1v1h-1M10,7h1v1h-1M10,8h1v1h-1M10,9h1v1h-1M10,10h1v1h-1M10,12h1v1h-1M10,14h1v1h-1M10,16h1v1h-1M10,18h1v1h-1M10,20h1v1h-1M10,22h1v1h-1M10,24h1v1h-1M10,26h1v1h-1M10,27h1v1h-1M10,28h1v1h-1M10,29h1v1h-1M10,30h1v1h-1M10,31h1v1h-1M10,32h1v1h-1M11,12h1v.5h-1M11,13h1v.5h-1M11,15h1v.5h-1M11,16h1v.5h-1M11,17h1v.5h-1M11,18h1v.5h-1M11,19h1v.5h-1M12,6h1v1h-1M12,7h1v1h-1M12,8h1v1h-1M12,10h1v1h-1M12,12h1v1h-1M12,20h1v1h-1M12,22h1v1h-1M12,23h1v1h-1M12,24h1v1h-1M12,25h1v1h-1M12,26h1v1h-1M12,27h1v1h-1M12,30h1v1h-1M12,31h1v1h-1M12,32h1v1h-1M13,9h1v.5h-1M13,11h1v.5h-1M13,12h1v.5h-1M13,13h1v.5h-1M13,14h1v.5h-1M13,15h1v.5h-1M13,16h1v.5h-1M13,18h1v.5h-1M13,20h1v.5h-1M13,25h1v.5h-1M13,26h1v.5h-1M13,27h1v.5h-1M13,28h1v.5h-1M13,29h1v.5h-1M13,30h1v.5h-1M13,32h1v.5h-1M14,4h1v1h-1M14,6h1v1h-1M14,7h1v1h-1M14,9h1v1h-1M14,10h1v1h-1M14,12h1v1h-1M14,13h1v1h-1M14,14h1v1h-1M14,15h1v1h-1M14,16h1v1h-1M14,17h1v1h-1M14,18h1v1h-1M14,19h1v1h-1M14,20h1v1h-1M14,22h1v1h-1M14,24h1v1h-1M14,25h1v1h-1M14,26h1v1h-1M14,27h1v1h-1M15,4h1v.5h-1M15,6h1v.5h-1M15,8h1v.5h-1M15,9h1v.5h-1M15,11h1v.5h-1M15,12h1v.5h-1M15,13h1v.5h-1M15,15h1v.5h-1M15,16h1v.5h-1M15,18h1v.5h-1M15,20h1v.5h-1M15,21h1v.5h-1M15,22h1v.5h-1M15,25h1v.5h-1M15,26h1v.5h-1M15,27h1v.5h-1M15,29h1v.5h-1M15,31h1v.5h-1M16,5h1v1h-1M16,7h1v1h-1M16,9h1v1h-1M16,10h1v1h-1M16,11h1v1h-1M16,12h1v1h-1M16,14h1v1h-1M16,17h1v1h-1M16,24h1v1h-1M16,25h1v1h-1M16,27h1v1h-1M16,30h1v1h-1M16,31h1v1h-1M16,32h1v1h-1M17,5h1v.5h-1M17,6h1v.5h-1M17,8h1v.5h-1M17,9h1v.5h-1M17,12h1v.5h-1M17,16h1v.5h-1M17,18h1v.5h-1M17,20h1v.5h-1M17,23h1v.5h-1M17,24h1v.5h-1M17,25h1v.5h-1M17,26h1v.5h-1M17,28h1v.5h-1M17,29h1v.5h-1M17,31h1v.5h-1M17,32h1v.5h-1M18,4h1v1h-1M18,5h1v1h-1M18,7h1v1h-1M18,9h1v1h-1M18,10h1v1h-1M18,12h1v1h-1M18,13h1v1h-1M18,14h1v1h-1M18,16h1v1h-1M18,19h1v1h-1M18,20h1v1h-1M18,22h1v1h-1M18,24h1v1h-1M18,26h1v1h-1M18,27h1v1h-1M19,4h1v.5h-1M19,6h1v.5h-1M19,7h1v.5h-1M19,8h1v.5h-1M19,12h1v.5h-1M19,13h1v.5h-1M19,16h1v.5h-1M19,21h1v.5h-1M19,22h1v.5h-1M19,24h1v.5h-1M19,28h1v.5h-1M19,29h1v.5h-1M19,31h1v.5h-1M20,5h1v1h-1M20,6h1v1h-1M20,8h1v1h-1M20,9h1v1h-1M20,10h1v1h-1M20,13h1v1h-1M20,14h1v1h-1M20,16h1v1h-1M20,19h1v1h-1M20,20h1v1h-1M20,25h1v1h-1M20,29h1v1h-1M20,30h1v1h-1M20,31h1v1h-1M21,4h1v.5h-1M21,6h1v.5h-1M21,7h1v.5h-1M21,8h1v.5h-1M21,12h1v.5h-1M21,14h1v.5h-1M21,16h1v.5h-1M21,17h1v.5h-1M21,19h1v.5h-1M21,20h1v.5h-1M21,24h1v.5h-1M21,25h1v.5h-1M21,26h1v.5h-1M21,27h1v.5h-1M21,28h1v.5h-1M21,29h1v.5h-1M21,31h1v.5h-1M21,32h1v.5h-1M22,4h1v1h-1M22,7h1v1h-1M22,8h1v1h-1M22,10h1v1h-1M22,13h1v1h-1M22,15h1v1h-1M22,17h1v1h-1M22,19h1v1h-1M22,20h1v1h-1M22,21h1v1h-1M22,23h1v1h-1M22,26h1v1h-1M22,27h1v1h-1M22,29h1v1h-1M23,4h1v.5h-1M23,6h1v.5h-1M23,9h1v.5h-1M23,11h1v.5h-1M23,13h1v.5h-1M23,14h1v.5h-1M23,15h1v.5h-1M23,16h1v.5h-1M23,19h1v.5h-1M23,20h1v.5h-1M23,21h1v.5h-1M23,23h1v.5h-1M23,24h1v.5h-1M23,26h1v.5h-1M23,28h1v.5h-1M23,31h1v.5h-1M24,4h1v1h-1M24,6h1v1h-1M24,7h1v1h-1M24,9h1v1h-1M24,10h1v1h-1M24,12h1v1h-1M24,14h1v1h-1M24,15h1v1h-1M24,16h1v1h-1M24,17h1v1h-1M24,18h1v1h-1M24,19h1v1h-1M24,20h1v1h-1M24,22h1v1h-1M24,23h1v1h-1M24,24h1v1h-1M24,25h1v1h-1M24,26h1v1h-1M24,27h1v1h-1M24,28h1v1h-1M24,30h1v1h-1M25,12h1v.5h-1M25,16h1v.5h-1M25,18h1v.5h-1M25,20h1v.5h-1M25,21h1v.5h-1M25,22h1v.5h-1M25,24h1v.5h-1M25,28h1v.5h-1M25,29h1v.5h-1M25,32h1v.5h-1M26,4h1v1h-1M26,5h1v1h-1M26,6h1v1h-1M26,7h1v1h-1M26,8h1v1h-1M26,9h1v1h-1M26,10h1v1h-1M26,14h1v1h-1M26,16h1v1h-1M26,17h1v1h-1M26,18h1v1h-1M26,19h1v1h-1M26,21h1v1h-1M26,22h1v1h-1M26,23h1v1h-1M26,24h1v1h-1M26,26h1v1h-1M26,28h1v1h-1M27,4h1v.5h-1M27,10h1v.5h-1M27,13h1v.5h-1M27,14h1v.5h-1M27,15h1v.5h-1M27,16h1v.5h-1M27,17h1v.5h-1M27,19h1v.5h-1M27,20h1v.5h-1M27,22h1v.5h-1M27,23h1v.5h-1M27,24h1v.5h-1M27,28h1v.5h-1M27,29h1v.5h-1M28,4h1v1h-1M28,6h1v1h-1M28,7h1v1h-1M28,8h1v1h-1M28,10h1v1h-1M28,12h1v1h-1M28,13h1v1h-1M28,16h1v1h-1M28,20h1v1h-1M28,21h1v1h-1M28,22h1v1h-1M28,24h1v1h-1M28,25h1v1h-1M28,26h1v1h-1M28,27h1v1h-1M28,28h1v1h-1M28,29h1v1h-1M28,30h1v1h-1M28,32h1v1h-1M29,4h1v.5h-1M29,6h1v.5h-1M29,7h1v.5h-1M29,8h1v.5h-1M29,10h1v.5h-1M29,12h1v.5h-1M29,13h1v.5h-1M29,15h1v.5h-1M29,16h1v.5h-1M29,17h1v.5h-1M29,18h1v.5h-1M29,22h1v.5h-1M29,23h1v.5h-1M29,24h1v.5h-1M29,25h1v.5h-1M29,27h1v.5h-1M29,29h1v.5h-1M29,30h1v.5h-1M30,4h1v1h-1M30,6h1v1h-1M30,7h1v1h-1M30,8h1v1h-1M30,10h1v1h-1M30,12h1v1h-1M30,13h1v1h-1M30,14h1v1h-1M30,16h1v1h-1M30,18h1v1h-1M30,20h1v1h-1M30,21h1v1h-1M30,22h1v1h-1M30,23h1v1h-1M30,24h1v1h-1M30,25h1v1h-1M30,26h1v1h-1M30,27h1v1h-1M30,28h1v1h-1M30,30h1v1h-1M30,31h1v1h-1M31,4h1v.5h-1M31,10h1v.5h-1M31,13h1v.5h-1M31,18h1v.5h-1M31,19h1v.5h-1M31,20h1v.5h-1M31,21h1v.5h-1M31,26h1v.5h-1M31,28h1v.5h-1M31,29h1v.5h-1M31,31h1v.5h-1M32,4h1v1h-1M32,5h1v1h-1M32,6h1v1h-1M32,7h1v1h-1M32,8h1v1h-1M32,9h1v1h-1M32,10h1v1h-1M32,14h1v1h-1M32,15h1v1h-1M32,16h1v1h-1M32,17h1v1h-1M32,18h1v1h-1M32,19h1v1h-1M32,22h1v1h-1M32,26h1v1h-1M32,28h1v1h-1M32,30h1v1h-1"
91 /// fill="#000000" />
92 /// </svg>
93 Commandrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Command#(ModuleFunctionrust-analyzer cargo fast_qr 0.13.1 convert/ModuleFunction#),
94 }
95
96 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#> for usize {
97 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[usize][`From<Shape>`]from().(shape: Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[usize][`From<Shape>`] {
98 match shape {
99 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Squarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Square# => 0,
100 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Circlerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Circle# => 1,
101 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::RoundedSquarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#RoundedSquare# => 2,
102 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Verticalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Vertical# => 3,
103 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Horizontalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Horizontal# => 4,
104 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Diamondrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Diamond# => 5,
105 #[cfg(not(feature = "wasm-bindgen"))]
106 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Commandrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Command#(_) => 6,
107 }
108 }
109 }
110
111 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape# {
112 #[allow(clippy::match_same_arms)]
113 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][`From<String>`]from().(shape: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][`From<String>`] {
114 match shape.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() {
115 "square" => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Squarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Square#,
116 "circle" => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Circlerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Circle#,
117 "rounded_square" => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::RoundedSquarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#RoundedSquare#,
118 "vertical" => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Verticalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Vertical#,
119 "horizontal" => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Horizontalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Horizontal#,
120 "diamond" => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Diamondrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Diamond#,
121
122 _ => Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Squarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Square#,
123 }
124 }
125 }
126
127 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#> for &str {
128 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[`&str`][`From<Shape>`]from().(shape: Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[`&str`][`From<Shape>`] {
129 match shape {
130 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Squarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Square# => "square",
131 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Circlerust-analyzer cargo fast_qr 0.13.1 convert/Shape#Circle# => "circle",
132 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::RoundedSquarerust-analyzer cargo fast_qr 0.13.1 convert/Shape#RoundedSquare# => "rounded_square",
133 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Verticalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Vertical# => "vertical",
134 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Horizontalrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Horizontal# => "horizontal",
135 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Diamondrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Diamond# => "diamond",
136 #[cfg(not(feature = "wasm-bindgen"))]
137 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::Commandrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Command#(_) => "command",
138 }
139 }
140 }
141
142 impl Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape# {
143 pub(craterust-analyzer cargo fast_qr 0.13.1 crate/) fn squarerust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]square().(y: usize, x: usize, _: Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
144 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("M{x},{y}h1v1h-1")
145 }
146
147 pub(craterust-analyzer cargo fast_qr 0.13.1 crate/) fn circlerust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]circle().(y: usize, x: usize, _: Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
148 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("M{},{y}.5a.5,.5 0 1,1 0,-.1", x +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1)
149 }
150
151 pub(craterust-analyzer cargo fast_qr 0.13.1 crate/) fn rounded_squarerust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]rounded_square().(y: usize, x: usize, _: Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
152 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("M{x}.2,{y}.2 {x}.8,{y}.2 {x}.8,{y}.8 {x}.2,{y}.8z")
153 }
154
155 pub(craterust-analyzer cargo fast_qr 0.13.1 crate/) fn horizontalrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]horizontal().(y: usize, x: usize, _: Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
156 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("M{x},{y}.1h1v.8h-1")
157 }
158
159 pub(craterust-analyzer cargo fast_qr 0.13.1 crate/) fn verticalrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]vertical().(y: usize, x: usize, _: Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
160 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("M{x}.1,{y}h.8v1h-.8")
161 }
162
163 pub(craterust-analyzer cargo fast_qr 0.13.1 crate/) fn diamondrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]diamond().(y: usize, x: usize, _: Modulerust-analyzer cargo fast_qr 0.13.1 module/Module#) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
164 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("M{x}.5,{y}l.5,.5l-.5,.5l-.5,-.5z")
165 }
166
167 const FUNCTIONSrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]FUNCTIONS.: [ModuleFunctionrust-analyzer cargo fast_qr 0.13.1 convert/ModuleFunction#; 6] = [
168 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::squarerust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]square().,
169 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::circlerust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]circle().,
170 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::rounded_squarerust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]rounded_square().,
171 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::verticalrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]vertical().,
172 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::horizontalrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]horizontal().,
173 Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#::diamondrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]diamond().,
174 ];
175 }
176
177 impl Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref# for Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape# {
178 type Targetrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][Deref]Target# = ModuleFunctionrust-analyzer cargo fast_qr 0.13.1 convert/ModuleFunction#;
179
180 fn derefrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][Deref]deref().(&self) -> &Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][Deref]::Targetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#Target# {
181 let index: usize = (*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().();
182 match self {
183 #[cfg(not(feature = "wasm-bindgen"))]
184 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][Deref]::Commandrust-analyzer cargo fast_qr 0.13.1 convert/Shape#Command#(func) => func,
185 _ => &Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape][Deref]::FUNCTIONSrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Shape]FUNCTIONS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().,
186 }
187 }
188 }
189
190 /// Different possible image background shapes
191 #[cfg_attr(feature = "wasm-bindgen", repr(C), wasm_bindgen)]
192 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord:, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd:)]
193 pub enum ImageBackgroundShaperust-analyzer cargo fast_qr 0.13.1 convert/ImageBackgroundShape# {
194 /// Square shape
195 Squarerust-analyzer cargo fast_qr 0.13.1 convert/ImageBackgroundShape#Square#,
196 /// Circle shape
197 Circlerust-analyzer cargo fast_qr 0.13.1 convert/ImageBackgroundShape#Circle#,
198 /// Rounded square shape
199 RoundedSquarerust-analyzer cargo fast_qr 0.13.1 convert/ImageBackgroundShape#RoundedSquare#,
200 }
201
202 /// Contains possible errors for a conversion
203 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
204 pub enum ConvertErrorrust-analyzer cargo fast_qr 0.13.1 convert/ConvertError# {
205 /// Contains error message for a SVG conversion
206 #[cfg(feature = "svg")]
207 #[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
208 Svgrust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Svg#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
209 /// Contains error message for an Image conversion
210 #[cfg(feature = "image")]
211 #[cfg_attr(docsrs, doc(cfg(feature = "image")))]
212 Imagerust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Image#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
213 /// Contains error message if a file write failed
214 Iorust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Io#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#),
215 }
216
217 #[cfg(feature = "svg")]
218 #[cfg_attr(docsrs, doc(cfg(feature = "svg")))]
219 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<SvgErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#> for ConvertErrorrust-analyzer cargo fast_qr 0.13.1 convert/ConvertError# {
220 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<SvgError>`]from().(err: SvgErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<SvgError>`] {
221 match err {
222 SvgErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#::SvgErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#SvgError#(svg_err) => Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<SvgError>`]::Svgrust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Svg#(svg_err),
223 #[cfg(not(feature = "wasm-bindgen"))]
224 SvgErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#::IoErrorrust-analyzer cargo fast_qr 0.13.1 convert/svg/SvgError#IoError#(io_err) => Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<SvgError>`]::Iorust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Io#(io_err),
225 }
226 }
227 }
228
229 #[cfg(feature = "image")]
230 #[cfg_attr(docsrs, doc(cfg(feature = "image")))]
231 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#> for ConvertErrorrust-analyzer cargo fast_qr 0.13.1 convert/ConvertError# {
232 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<ImageError>`]from().(err: ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<ImageError>`] {
233 match err {
234 ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#::EncodingErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#EncodingError#(image_err) => Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<ImageError>`]::Imagerust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Image#(image_err),
235 ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#::ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#ImageError#(image_err) => Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<ImageError>`]::Imagerust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Image#(image_err),
236 ImageErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#::IoErrorrust-analyzer cargo fast_qr 0.13.1 convert/image/ImageError#IoError#(io_err) => Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[ConvertError][`From<ImageError>`]::Iorust-analyzer cargo fast_qr 0.13.1 convert/ConvertError#Io#(io_err),
237 }
238 }
239 }
240
241 /// Converts an array of pixel color to it's hexadecimal representation
242 /// # Example
243 /// ```rust
244 /// # use fast_qr::convert::rgba2hex;
245 /// let color = [0, 0, 0, 255];
246 /// assert_eq!(&rgba2hex(color), "#000000");
247 /// ```
248 #[must_use]
249 pub fn rgba2hexrust-analyzer cargo fast_qr 0.13.1 convert/rgba2hex().(color: [u8; 4]) -> Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# {
250 let mut hex = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::with_capacityrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]with_capacity().(9);
251
252 hex.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push().('#');
253 hex.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:02x}", color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
254 hex.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:02x}", color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
255 hex.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:02x}", color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
256 if color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().255 {
257 hex.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:02x}", color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().));
258 }
259
260 hex
261 }
262
263 /// Allows to take String, string slices, arrays or slices of u8 (3 or 4) to create a [Color]
264 pub struct Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color#(pub Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
265
266 impl Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
267 /// Returns the contained color
268 #[must_use]
269 pub fn to_strrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color]to_str().(&self) -> &str {
270 &self.0rust-analyzer cargo fast_qr 0.13.1 convert/Color#0.
271 }
272 }
273
274 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> for Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
275 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<String>`]from().(color: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<String>`] {
276 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<String>`](color)
277 }
278 }
279
280 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&str> for Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
281 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&str>`]from().(color: &str) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&str>`] {
282 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&str>`](color.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().())
283 }
284 }
285
286 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[u8; 4]> for Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
287 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 4]>`]from().(color: [u8; 4]) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 4]>`] {
288 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 4]>`](rgba2hexrust-analyzer cargo fast_qr 0.13.1 convert/rgba2hex().(color))
289 }
290 }
291
292 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<[u8; 3]> for Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
293 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 3]>`]from().(color: [u8; 3]) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 3]>`] {
294 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 3]>`]::fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 4]>`]from().([color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()., 255])
295 }
296 }
297
298 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&[u8]> for Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
299 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&[u8]>`]from().(color: &[u8]) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&[u8]>`] {
300 if color.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().3 {
301 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&[u8]>`]::fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 3]>`]from().([color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().])
302 } else if color.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().4 {
303 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&[u8]>`]::fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<[u8; 4]>`]from().([color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., color[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().3]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().])
304 } else {
305 panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("Invalid color length");
306 }
307 }
308 }
309
310 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>> for Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color# {
311 fn fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<Vec<u8>>`]from().(color: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8>) -> Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<Vec<u8>>`] {
312 Selfrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<Vec<u8>>`]::fromrust-analyzer cargo fast_qr 0.13.1 convert/impl#[Color][`From<&[u8]>`]from().(&color[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFull#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().)
313 }
314 }
315
316 /// Trait for `SvgBuilder` and `ImageBuilder`
317 pub trait Builderrust-analyzer cargo fast_qr 0.13.1 convert/Builder# {
318 /// Updates margin (default: 4)
319 fn marginrust-analyzer cargo fast_qr 0.13.1 convert/Builder#margin().(&mut self, margin: usize) -> &mut Self;
320 /// Updates module color (default: #000000)
321 fn module_colorrust-analyzer cargo fast_qr 0.13.1 convert/Builder#module_color().<C: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color#>>(&mut self, module_color: C) -> &mut Self;
322 /// Updates background color (default: #FFFFFF)
323 fn background_colorrust-analyzer cargo fast_qr 0.13.1 convert/Builder#background_color().<C: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color#>>(&mut self, background_color: C) -> &mut Self;
324 /// Adds a shape to the shapes list
325 fn shaperust-analyzer cargo fast_qr 0.13.1 convert/Builder#shape().(&mut self, shape: Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#) -> &mut Self;
326 /// Add a shape to the shapes list with a specific color
327 fn shape_colorrust-analyzer cargo fast_qr 0.13.1 convert/Builder#shape_color().<C: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color#>>(&mut self, shape: Shaperust-analyzer cargo fast_qr 0.13.1 convert/Shape#, color: C) -> &mut Self;
328
329 // Manages the image part
330
331 /// Provides the image path or an base64 encoded image
332 fn imagerust-analyzer cargo fast_qr 0.13.1 convert/Builder#image().(&mut self, image: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> &mut Self;
333 /// Updates the image background color (default: #FFFFFF)
334 fn image_background_colorrust-analyzer cargo fast_qr 0.13.1 convert/Builder#image_background_color().<C: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Colorrust-analyzer cargo fast_qr 0.13.1 convert/Color#>>(&mut self, image_background_color: C) -> &mut Self;
335 /// Updates the image background shape (default: Square)
336 fn image_background_shaperust-analyzer cargo fast_qr 0.13.1 convert/Builder#image_background_shape().(&mut self, image_background_shape: ImageBackgroundShaperust-analyzer cargo fast_qr 0.13.1 convert/ImageBackgroundShape#)
337 -> &mut Self;
338 /// Updates the image size and the gap between the image and the [`crate::QRCode`]
339 /// Default is around 30% of the [`crate::QRCode`] size
340 fn image_sizerust-analyzer cargo fast_qr 0.13.1 convert/Builder#image_size().(&mut self, image_size: f64) -> &mut Self;
341 /// Updates the gap between the image and the [`crate::QRCode`]
342 fn image_gaprust-analyzer cargo fast_qr 0.13.1 convert/Builder#image_gap().(&mut self, gap: f64) -> &mut Self;
343 /// Updates the image position, anchor is the center of the image. Default is the center of the [`crate::QRCode`]
344 fn image_positionrust-analyzer cargo fast_qr 0.13.1 convert/Builder#image_position().(&mut self, x: f64, y: f64) -> &mut Self;
345 }