Skip to main content

ConversionOptions

Struct ConversionOptions 

Source
pub struct ConversionOptions {
Show 13 fields pub dpi: Option<i64>, pub rotation: Option<i64>, pub scaling: Option<f64>, pub color_mode: Option<ColorMode>, pub darkness: Option<i64>, pub position: Option<Position>, pub watermark: Option<bool>, pub dialect: Option<String>, pub data: Option<Vec<Value>>, pub label: Option<LabelSize>, pub pdf: Option<PdfOptions>, pub zpl: Option<ZplOptions>, pub extra: Map<String, Value>,
}
Expand description

The conversion parameters, in the shape the API expects.

Every field is an Option and only the ones you set are sentskip_serializing_if is rule C1 expressed in the type system. The SDK never fills in a client-side default, so a change to a server default reaches you without a crate upgrade. Setting nothing at all produces a bare URL with no query string.

Fields§

§dpi: Option<i64>

Output resolution. Server default 203.

§rotation: Option<i64>

Degrees clockwise. Must be a multiple of 90. Server default 0.

§scaling: Option<f64>

Percentage. Server default 100.

§color_mode: Option<ColorMode>

Colour reduction. Server default GRAYSCALE.

§darkness: Option<i64>

Luminance threshold from 0 to 100. Server default 70.

§position: Option<Position>

Pixel offset of the extracted region.

§watermark: Option<bool>

Forced on for the anonymous free tier regardless of what you set.

§dialect: Option<String>

A printer dialect, e.g. "moca". Requires a paid license.

§data: Option<Vec<Value>>

The variable-field values, one entry per output label.

Typed as Vec<Value> rather than Vec<Map<String, Value>> so that a non-object element is expressible and can be rejected with a ValidationError – which is what lets this crate run validation/data-element-not-an-object rather than declaring it away. Use ConversionOptions::with_data to build it from records.

§label: Option<LabelSize>

The media size, in INCHES. Leave None to have the server detect it.

§pdf: Option<PdfOptions>

How a PDF source is read.

§zpl: Option<ZplOptions>

ZPL output settings.

§extra: Map<String, Value>

Anything this crate does not model yet. Unknown keys are ignored server-side, so this is a safe forward-compatibility escape hatch. Merged at the top level of the params object.

Implementations§

Source§

impl ConversionOptions

Source

pub fn new() -> Self

Fresh options with nothing set, which sends no query string at all.

Source

pub fn dpi(self, dpi: i64) -> Self

Sets the output resolution.

Source

pub fn rotation(self, degrees: i64) -> Self

Sets the rotation, in degrees clockwise. Must be a multiple of 90.

Source

pub fn scaling(self, percent: f64) -> Self

Sets the scaling percentage.

Source

pub fn color_mode(self, mode: ColorMode) -> Self

Sets the colour mode.

Source

pub fn darkness(self, darkness: i64) -> Self

Sets the luminance threshold, 0 to 100.

Source

pub fn position(self, x: i64, y: i64) -> Self

Sets the pixel offset of the extracted region.

Source

pub fn watermark(self, watermark: bool) -> Self

Turns the watermark on or off. An explicit false is sent.

Source

pub fn dialect(self, dialect: impl Into<String>) -> Self

Sets the printer dialect. Requires a paid license.

Source

pub fn label_size(self, width_inches: f64, height_inches: f64) -> Self

Sets the media size, in inches.

Source

pub fn pdf_conversion_mode(self, mode: PdfConversionMode) -> Self

Sets how a PDF source is read.

Source

pub fn pdf_page(self, zero_based_page_number: i64) -> Self

Selects a single PDF page. Zero-based; omit to convert every page.

Source

pub fn zpl_commands_to_ignore<I, S>(self, commands: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Drops the named commands from ZPL output.

Source

pub fn zpl_image_compression(self, compression: ZplImageCompression) -> Self

Sets the encoding of images embedded in ZPL output.

Source

pub fn with_data<I>(self, records: I) -> Self
where I: IntoIterator<Item = Map<String, Value>>,

Sets the variable-field values, one record per output label.

Source

pub fn extra(self, key: impl Into<String>, value: impl Into<Value>) -> Self

Adds a parameter this crate does not model. Unknown keys are ignored server-side.

Trait Implementations§

Source§

impl Clone for ConversionOptions

Source§

fn clone(&self) -> ConversionOptions

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 ConversionOptions

Source§

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

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

impl Default for ConversionOptions

Source§

fn default() -> ConversionOptions

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

impl PartialEq for ConversionOptions

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for ConversionOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ConversionOptions

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 = !

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.