Expand description
QRCode encoder
This crate provides a QR code and Micro QR code encoder for binary data.
use qrcode_rs::QrCode;
use image::Luma;
// Encode some data into bits.
let code = QrCode::new(b"01234567").unwrap();
// Render the bits into an image.
let image = code.render::<Luma<u8>>().build();
// Save the image.
image.save("/tmp/qrcode.png").unwrap();
// You can also render it into a string.
let string = code.render()
.light_color(' ')
.dark_color('#')
.build();
println!("{}", string);Re-exports§
pub use qrcode_decode as decode;pub use qrcode_parse as parse;
Modules§
- bits
- Bit-level data encoding for QR codes.
- canvas
- QR code canvas construction and masking.
- ec
- Reed-Solomon error correction for QR codes.
- optimize
- Data mode segmentation optimizer.
- plugin
- Explicit plugin registry and object-safe extension points.
- render
- Rendering facade.
- structured_
append - ISO/IEC 18004 §7.4 Structured Append — splitting one payload across 2..=16 QR symbols.
- traits
- Core extension traits for encoding, rendering, and module-grid storage.
- types
- Core data types: module
Color,EcLevel,Version,Mode, theQrError/QrResulterror types, and string-parsing helpers.
Structs§
- Alphanumeric
Mode - Type-level alphanumeric mode marker.
- Analysis
- Diagnostic stats for a constructed
QrCode, returned byQrCode::analyze. - Auto
Encoder - Encoder adapter for automatically sized normal QR codes.
- Byte
Mode - Type-level byte mode marker.
- Const
Version - A compile-time checked normal QR version.
- Const
Version Encoder - Encoder adapter for a compile-time checked normal QR version and
EcLevel. - Dark
Modules - Iterator over the
(x, y)coordinates of every dark module in aQrCode, created byQrCode::dark_modules. - Encode
Config - Runtime encoder configuration passed to encoder factories.
- Info
- Metadata about a constructed
QrCode, returned byQrCode::info. - Kanji
Mode - Type-level Shift-JIS Kanji mode marker.
- Micro
Encoder - Encoder adapter for automatically sized Micro QR codes.
- Module
Grid - Owned mutable module grid used by plugin postprocessors.
- Module
View - Borrowed row-major view over a read-only QR module grid.
- Numeric
Mode - Type-level numeric mode marker.
- Plugin
Registry - Explicit plugin registry.
- QrCode
- The encoded QR code symbol.
- QrCode
Builder - A builder for
QrCode, offering ergonomic, chainable configuration. - QrCode
Data serde - A serializable view of a
QrCode(matrix + metadata), enabled by theserdefeature. Round-trips viaQrCode::to_serializableandQrCode::from_serializable. - QrCode
Plugins - Borrowed plugin view for a QR code.
- QrCode
Ref - Borrowed QR symbol with module-grid data and QR metadata.
- QrCode
Stream - Lazy iterator returned by
QrCode::streamandQrCode::stream_with_error_correction_level. - QrTemplate
- A reusable render-time style: dark/light hex colors, module size, and quiet
zone. Apply to a
RendererwithRenderer::templatewhen the pixel type is aStyledPixel. - Render
Config - Runtime renderer configuration passed to renderer factories.
- Row
- A single row of modules, yielded by
Rows. Iterates overColors from left to right (quiet zone excluded). - Rows
- Iterator over the rows of a
QrCode, created byQrCode::rows. - Version
Encoder - Encoder adapter for a pinned
VersionandEcLevel.
Enums§
- Color
- The color of a module.
- EcLevel
- The error correction level. It allows the original information be recovered even if parts of the code is damaged.
- Encoded
Output - Type-erased encode output returned by dynamic encoders.
- Mode
- The mode indicator, which specifies the character set of the encoded data.
- Plugin
Error - Error type used by object-safe plugin entry points.
- QrError
QrErrorencodes the error encountered when generating a QR code.- Render
Output - Type-erased render output returned by dynamic renderers.
- Version
- In QR code terminology,
Versionmeans the size of the generated image. Larger version means the size of code is larger, and therefore can carry more information.
Traits§
- Builder
- Builds a configured value into its final output.
- Core
Renderer - Renders a module-grid source into a concrete output type.
- DynEncoder
- Object-safe encoder used by
EncoderFactory. - DynRenderer
- Object-safe renderer used by
RendererFactory. - Encoder
- Encodes raw input bytes into a concrete output type.
- Encoder
Factory - Factory for object-safe encoders.
- Encoding
Mode - A type-level QR encoding mode.
- Module
Source - Read-only access to a QR module grid.
- Module
Storage - Read/write access to a QR module grid.
- Post
Processor - Object-safe postprocessor for in-place module-grid transforms.
- QrPlugin
- A plugin that registers one or more extension points.
- QrSymbol
- Read-only QR symbol metadata plus module-grid access.
- Renderer
Factory - Factory for object-safe renderers.
- Static
Version - A type-level fixed QR version.
Type Aliases§
- QrResult
QrResultis a convenient alias for a QR code generation result.