Skip to main content

laravel_qrcode/
lib.rs

1//! QR codes for [Laravel Rust](https://laravel.com/rust), the counterpart of the PHP package
2//! `simplesoftwareio/simple-qrcode`.
3//!
4//! The crate has two layers:
5//!
6//! - The **core** ([`QrCode`], [`payload`], [`Error`]) does not depend on any framework and
7//!   compiles with `--no-default-features`. It renders SVG, and PNG with the `png` feature.
8//! - The **`laravel` feature** (on by default) adds [`integration`]: the [`QrCodeConfig`] section
9//!   (`QRCODE_*` variables), the [`QrCodeServiceProvider`], [`QrCodeFactory`] and response
10//!   helpers. The `minijinja` feature adds `qrcode(..)` and `qrcode_uri(..)` to the framework's
11//!   views.
12//!
13//! ```
14//! use laravel_qrcode::{QrCode, payload};
15//!
16//! let svg = QrCode::new().size(200).svg(payload::wifi("Office", "s3cret")).unwrap();
17//! assert!(svg.starts_with("<?xml"));
18//! ```
19//!
20//! Encoding is done by the [`qrcode`](https://crates.io/crates/qrcode) crate. This crate only
21//! draws the modules, so there is no image-processing dependency tree.
22
23mod base64;
24mod error;
25mod options;
26pub mod payload;
27#[cfg(feature = "png")]
28mod png;
29mod qr;
30mod svg;
31
32#[cfg(feature = "laravel")]
33pub mod integration;
34
35pub use error::{Error, Result};
36pub use options::{Color, Encoding, ErrorCorrection, Style};
37#[cfg(feature = "png")]
38pub use qr::MAX_LOGO_RATIO;
39pub use qr::{Matrix, QrCode};
40
41#[cfg(feature = "laravel")]
42pub use integration::{QrCodeConfig, QrCodeFactory, QrCodeServiceProvider};