#[non_exhaustive]pub struct QRCode {
pub data: Vec<u8>,
/* private fields */
}
Expand description
Re-exported main qrc
module from qrc for QR code generation.
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
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) -> QRCode
pub fn from_string(data: String) -> QRCode
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>) -> QRCode
pub fn from_bytes(data: Vec<u8>) -> QRCode
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 ImageBuffer<Rgba<u8>, Vec<u8>>,
watermark: &ImageBuffer<Rgba<u8>, Vec<u8>>,
)
pub fn add_image_watermark( img: &mut ImageBuffer<Rgba<u8>, Vec<u8>>, watermark: &ImageBuffer<Rgba<u8>, Vec<u8>>, )
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_dynamic(initial_data: &str) -> QRCode
pub fn create_dynamic(initial_data: &str) -> QRCode
Sourcepub fn overlay_image(
&self,
overlay: &ImageBuffer<Rgba<u8>, Vec<u8>>,
) -> ImageBuffer<Rgba<u8>, Vec<u8>>
pub fn overlay_image( &self, overlay: &ImageBuffer<Rgba<u8>, Vec<u8>>, ) -> ImageBuffer<Rgba<u8>, Vec<u8>>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§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>
ReadEndian::read_from_little_endian()
.