#[non_exhaustive]pub struct QRCode {
pub data: Vec<u8>,
/* private fields */
}
Expand description
Represents a QR code containing data.
This struct can be used to generate QR code images in various formats. It supports encoding data as a QR code and rendering it in formats like PNG, JPG, and SVG.
§Examples
use qrc::QRCode;
// Create a new QR code with text data
let qr = QRCode::new("Hello, world!".as_bytes().to_vec());
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.data: Vec<u8>
The data
field holds the data to be encoded in the QR code.
Implementations§
Source§impl QRCode
Implementation of QRCode structure.
impl QRCode
Implementation of QRCode structure.
Sourcepub fn from_string(data: String) -> Self
pub fn from_string(data: String) -> Self
The from_string
method creates a new instance of the QRCode
struct by converting the given string data into a vector of
bytes
Sourcepub fn from_bytes(data: Vec<u8>) -> Self
pub fn from_bytes(data: Vec<u8>) -> Self
Creates a new QRCode structure from a vector of bytes.
Sourcepub fn to_png(&self, width: u32) -> ImageBuffer<Rgba<u8>, Vec<u8>>
pub fn to_png(&self, width: u32) -> ImageBuffer<Rgba<u8>, Vec<u8>>
Converts the QRCode structure to a PNG image.
§Examples
use qrc::QRCode;
// Convert a string slice to a String using `.to_string()`
let qr = QRCode::from_string("Hello, world!".to_string());
let png_image = qr.to_png(256);
§Parameters
width
: The width of the image in pixels.
§Returns
An ImageBuffer
representing the QR code in PNG format.
Sourcepub fn add_image_watermark(img: &mut RgbaImage, watermark: &RgbaImage)
pub fn add_image_watermark(img: &mut RgbaImage, watermark: &RgbaImage)
Adds a watermark image to the QR code.
§Parameters
img
: A mutable reference to theRgbaImage
of the QR code.watermark
: A reference to the watermarkRgbaImage
.
Sourcepub fn create_multilanguage(data_map: HashMap<String, String>) -> Self
pub fn create_multilanguage(data_map: HashMap<String, String>) -> Self
Sourcepub fn create_dynamic(initial_data: &str) -> Self
pub fn create_dynamic(initial_data: &str) -> Self
Sourcepub fn overlay_image(&self, overlay: &RgbaImage) -> RgbaImage
pub fn overlay_image(&self, overlay: &RgbaImage) -> RgbaImage
Sourcepub fn set_encoding_format(&self, format: &str) -> Result<Self, &'static str>
pub fn set_encoding_format(&self, format: &str) -> Result<Self, &'static str>
Sourcepub fn get_encoding_format(&self) -> &str
pub fn get_encoding_format(&self) -> &str
Retrieves the encoding format of the QR code.
§Returns
A string slice representing the encoding format.
Trait Implementations§
Source§impl Ord for QRCode
impl Ord for QRCode
Source§impl PartialOrd for QRCode
impl PartialOrd for QRCode
impl Eq for QRCode
impl StructuralPartialEq for QRCode
Auto Trait Implementations§
impl Freeze for QRCode
impl RefUnwindSafe for QRCode
impl Send for QRCode
impl Sync for QRCode
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.