pub struct Renderer<'a> { /* private fields */ }micro-qr or qr or rmqr only.Expand description
Renders an encoded symbol at exact output dimensions.
Implementations§
Source§impl<'a> Renderer<'a>
impl<'a> Renderer<'a>
Sourcepub const fn new(symbol: &'a Symbol, size: usize) -> Self
pub const fn new(symbol: &'a Symbol, size: usize) -> Self
Creates a renderer with an exact square output size and the standard quiet zone for the symbol family.
Sourcepub const fn new_with_dimensions(
symbol: &'a Symbol,
width: usize,
height: usize,
) -> Self
pub const fn new_with_dimensions( symbol: &'a Symbol, width: usize, height: usize, ) -> Self
Creates a renderer with exact output dimensions and the standard quiet zone for the symbol family.
Sourcepub const fn quiet_zone(self, modules: usize) -> Self
pub const fn quiet_zone(self, modules: usize) -> Self
Sets the minimum quiet zone in modules before any extra centering pixels.
Sourcepub fn to_luma8(self) -> Result<Vec<u8>, RenderError>
pub fn to_luma8(self) -> Result<Vec<u8>, RenderError>
Renders an 8-bit grayscale image in row-major order.
Sourcepub fn write_svg<W: IoWrite>(
self,
writer: W,
description: Option<impl AsRef<str>>,
) -> Result<(), RenderError>
Available on crate feature std only.
pub fn write_svg<W: IoWrite>( self, writer: W, description: Option<impl AsRef<str>>, ) -> Result<(), RenderError>
std only.Writes an SVG document to a writer.
The description must contain only characters allowed by XML 1.0; markup characters are escaped, but callers must remove or replace disallowed XML characters before rendering.
Pass None::<&str> when no description is needed.
Sourcepub fn to_svg_string(
self,
description: Option<impl AsRef<str>>,
) -> Result<String, RenderError>
pub fn to_svg_string( self, description: Option<impl AsRef<str>>, ) -> Result<String, RenderError>
Renders an SVG document as a UTF-8 string.
The description must contain only characters allowed by XML 1.0; markup characters are escaped, but callers must remove or replace disallowed XML characters before rendering.
Pass None::<&str> when no description is needed.
Sourcepub async fn write_svg_async<W: TokioAsyncWrite + Unpin>(
self,
writer: W,
description: Option<impl AsRef<str>>,
) -> Result<(), RenderError>
Available on crate feature tokio only.
pub async fn write_svg_async<W: TokioAsyncWrite + Unpin>( self, writer: W, description: Option<impl AsRef<str>>, ) -> Result<(), RenderError>
tokio only.Renders an SVG document in memory, then writes and flushes it to a tokio asynchronous writer.
The description must contain only characters allowed by XML 1.0; markup characters are escaped, but callers must remove or replace disallowed XML characters before rendering.
Pass None::<&str> when no description is needed.
Sourcepub fn save_svg(
self,
path: impl AsRef<Path>,
description: Option<impl AsRef<str>>,
) -> Result<(), RenderError>
Available on crate feature std only.
pub fn save_svg( self, path: impl AsRef<Path>, description: Option<impl AsRef<str>>, ) -> Result<(), RenderError>
std only.Atomically saves an SVG document after rendering succeeds.
The description must contain only characters allowed by XML 1.0; markup characters are escaped, but callers must remove or replace disallowed XML characters before rendering.
Pass None::<&str> when no description is needed.
Sourcepub async fn save_svg_async(
self,
path: impl AsRef<Path>,
description: Option<impl AsRef<str>>,
) -> Result<(), RenderError>
Available on crate feature tokio only.
pub async fn save_svg_async( self, path: impl AsRef<Path>, description: Option<impl AsRef<str>>, ) -> Result<(), RenderError>
tokio only.Atomically saves an SVG document after rendering succeeds, offloading the write to tokio’s blocking pool.
Like save_svg, the write goes through a temporary file, so an existing file is left untouched if it fails.
The description must contain only characters allowed by XML 1.0; markup characters are escaped, but callers must remove or replace disallowed XML characters before rendering.
Pass None::<&str> when no description is needed.
Sourcepub fn write_png<W: IoWrite>(self, writer: W) -> Result<(), RenderError>
Available on crate feature image only.
pub fn write_png<W: IoWrite>(self, writer: W) -> Result<(), RenderError>
image only.Writes a grayscale PNG image to a writer.
Sourcepub fn to_png_vec(self) -> Result<Vec<u8>, RenderError>
Available on crate feature image only.
pub fn to_png_vec(self) -> Result<Vec<u8>, RenderError>
image only.Renders a grayscale PNG image into a byte vector.
Sourcepub async fn write_png_async<W: TokioAsyncWrite + Unpin>(
self,
writer: W,
) -> Result<(), RenderError>
Available on crate features image and tokio only.
pub async fn write_png_async<W: TokioAsyncWrite + Unpin>( self, writer: W, ) -> Result<(), RenderError>
image and tokio only.Renders a PNG image in memory, then writes and flushes it to a tokio asynchronous writer.
Sourcepub fn save_png(self, path: impl AsRef<Path>) -> Result<(), RenderError>
Available on crate feature image only.
pub fn save_png(self, path: impl AsRef<Path>) -> Result<(), RenderError>
image only.Atomically saves a PNG image after rendering succeeds.
Sourcepub async fn save_png_async(
self,
path: impl AsRef<Path>,
) -> Result<(), RenderError>
Available on crate features image and tokio only.
pub async fn save_png_async( self, path: impl AsRef<Path>, ) -> Result<(), RenderError>
image and tokio only.Atomically saves a PNG image after rendering succeeds, offloading the write to tokio’s blocking pool.
Like save_png, the write goes through a temporary file, so an existing file is left untouched if it fails.
Sourcepub fn to_image_buffer(
self,
) -> Result<ImageBuffer<Luma<u8>, Vec<u8>>, RenderError>
Available on crate feature image only.
pub fn to_image_buffer( self, ) -> Result<ImageBuffer<Luma<u8>, Vec<u8>>, RenderError>
image only.Renders a grayscale image buffer.
Trait Implementations§
impl<'a> Copy for Renderer<'a>
Source§impl Display for Renderer<'_>
Draws the symbol as compact Unicode text using half-block characters, with one module per column and two module rows per line.
impl Display for Renderer<'_>
Draws the symbol as compact Unicode text using half-block characters, with one module per column and two module rows per line.
The alternate form ({:#}) inverts dark and light modules for dark terminal backgrounds.
Pixel dimensions are ignored; only the quiet zone setting applies.
Each line ends with a newline.
Note: half-block characters have ambiguous East Asian width and may render as two columns in some CJK terminals, causing misalignment.