Skip to main content

RenderOptions

Struct RenderOptions 

Source
pub struct RenderOptions { /* private fields */ }
Expand description

How a symbol should be drawn.

Defaults target a 300 DPI thermal shipping-label printer: a 13 mil X-dimension, 25 mm bar height, standard quiet zones, and human-readable text.

§Examples

use smart_package_tracker::{Color, Length, QuietZone, RenderOptions};

let options = RenderOptions::builder()
    .module_width(Length::Mils(13.0))
    .height(Length::Mm(25.0))
    .quiet_zone(QuietZone::Standard)
    .dpi(300)
    .colors(Color::BLACK, Color::WHITE)
    .human_readable(true)
    .build()?;

assert_eq!(options.dpi(), 300);

Implementations§

Source§

impl RenderOptions

Source

pub fn builder() -> RenderOptionsBuilder

Start from the defaults and override what you need.

Source

pub fn module_width(&self) -> Length

The X-dimension: width of one module.

Source

pub fn height(&self) -> Length

Bar height, for linear symbologies.

Source

pub fn quiet_zone(&self) -> QuietZone

Quiet zone setting.

Source

pub fn dpi(&self) -> u32

Output resolution, used to convert physical lengths to pixels.

Source

pub fn foreground(&self) -> Color

Colour of dark modules.

Source

pub fn background(&self) -> Color

Colour of light modules and margins.

Source

pub fn human_readable(&self) -> bool

Whether to print the payload beneath the symbol.

Source

pub fn layout(&self, symbol: &Symbol) -> Result<Layout>

Compute the pixel geometry for symbol under these options.

Exposed because label layout often needs the final size before rendering.

§Errors

Returns Error::InvalidRenderOptions if the result would exceed 20,000 pixels on either axis, or 64 megapixels in total.

Trait Implementations§

Source§

impl Clone for RenderOptions

Source§

fn clone(&self) -> RenderOptions

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RenderOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RenderOptions

Source§

fn eq(&self, other: &RenderOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RenderOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.