pub struct QrCode { /* private fields */ }Expand description
A generated QR code ready for SVG rendering.
Create with QrCode::new (default error correction) or
QrCode::with_ecl (explicit level), then render via
QrCode::to_svg.
§Example
use modo::qrcode::{QrCode, QrStyle, Ecl};
let qr = QrCode::with_ecl("https://example.com", Ecl::High).unwrap();
let svg = qr.to_svg(&QrStyle::default()).unwrap();
assert!(svg.starts_with("<svg"));Implementations§
Source§impl QrCode
impl QrCode
Sourcepub fn new(data: &str) -> Result<Self, QrError>
pub fn new(data: &str) -> Result<Self, QrError>
Generate a QR code matrix with default error correction (Ecl::Medium).
Returns QrError::DataTooLong if the input exceeds QR capacity.
Sourcepub fn with_ecl(data: &str, ecl: Ecl) -> Result<Self, QrError>
pub fn with_ecl(data: &str, ecl: Ecl) -> Result<Self, QrError>
Generate a QR code matrix with the specified error correction level.
Returns QrError::DataTooLong if the input exceeds QR capacity
for the chosen level.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QrCode
impl RefUnwindSafe for QrCode
impl Send for QrCode
impl Sync for QrCode
impl Unpin for QrCode
impl UnsafeUnpin for QrCode
impl UnwindSafe for QrCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more