pub struct QrCode { /* private fields */ }Expand description
A finished QR symbol: a square grid of dark and light modules.
Implementations§
Source§impl QrCode
impl QrCode
Source§impl QrCode
impl QrCode
Sourcepub fn to_svg_default(&self) -> String
pub fn to_svg_default(&self) -> String
Render as a standalone <svg> element, four pixels per module and a
four-module quiet zone. The common case for an enrolment page.
Sourcepub fn to_svg(&self, module_pixels: u32, quiet_zone: u32) -> String
pub fn to_svg(&self, module_pixels: u32, quiet_zone: u32) -> String
Render as a standalone <svg> element with a default title.
module_pixels is the on-screen size of one module and quiet_zone the
margin around the symbol, in modules. The standard asks for at least
four, and readers really do need it — a QR code butted up against
surrounding content often will not scan.
Sourcepub fn to_svg_titled(
&self,
module_pixels: u32,
quiet_zone: u32,
title: &str,
) -> String
pub fn to_svg_titled( &self, module_pixels: u32, quiet_zone: u32, title: &str, ) -> String
Render as a standalone <svg> element with a caller-supplied title.
The output deliberately contains no <style> element, no style
attribute and no script: it is embedded in a page served under
style-src 'self'; script-src 'self' with no unsafe-inline, so
anything inline would simply be dropped by the browser and the code
would render as a blank square. Colours are presentation attributes,
which CSP does not police.
All of the dark modules go into one <path>, accumulated as horizontal
runs. A version 10 symbol has 3249 modules, and one element each would
be a document large enough to notice on every page load.