pub struct Options {
pub scale: u32,
pub bar_height: u32,
pub quiet_zone: u32,
pub include_text: bool,
pub foreground: [u8; 3],
pub background: [u8; 3],
pub extras: Vec<(String, String)>,
}Expand description
Module-level rendering options.
Fields§
§scale: u32Pixel multiplier for raster output, or stroke unit for vector output. Default: 4.
bar_height: u32Bar height in modules (only meaningful for 1D codes). Default: 50.
quiet_zone: u32Quiet zone in modules around the barcode. Default: 4.
include_text: boolWhether to render human-readable text under 1D symbologies.
foreground: [u8; 3]Foreground color as RGB. Default: black.
background: [u8; 3]Background color as RGB. Default: white.
extras: Vec<(String, String)>Symbology-specific options (e.g. ("eclevel", "M"), ("type", "29")).
Implementations§
Source§impl Options
impl Options
Sourcepub fn get(&self, key: &str) -> Option<&str>
pub fn get(&self, key: &str) -> Option<&str>
Look up an extra option by key (case-sensitive, like BWIPP).
§Example
use bwipp::Options;
let opts = Options::default().with("eclevel", "H");
assert_eq!(opts.get("eclevel"), Some("H"));
assert_eq!(opts.get("missing"), None);Sourcepub fn with(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add an option key=value. Designed to be chained as a builder.
§Example
use bwipp::{Options, Symbology, render_svg};
let opts = Options::default()
.with("eclevel", "Q")
.with("version", "5");
let svg = render_svg(Symbology::QrCode, "Hello", &opts).unwrap();
assert!(svg.starts_with("<svg"));Trait Implementations§
Auto Trait Implementations§
impl Freeze for Options
impl RefUnwindSafe for Options
impl Send for Options
impl Sync for Options
impl Unpin for Options
impl UnsafeUnpin for Options
impl UnwindSafe for Options
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