Struct SymbolList

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

Set of symbol sizes the encoder is allowed to use.

Specifies a list of symbol sizes the encoder will pick from. The smallest symbol which can hold the data is chosen.

By default all standard sizes defined in ISO 16022 are used. The selection can be restricted to square or rectangular symbols, symbols within a size range, or by giving an explicit list.

§Examples

To get all rectangles with maximum height 20, including the rectangle extensions you can write

let code = DataMatrix::encode(
    b"Hello, World!",
    SymbolList::with_extended_rectangles()
        .enforce_rectangular()
        .enforce_height_in(..=20),
);

Because SymbolSize and [SymbolSize; N] implement Into<SymbolList> you can write

// a) use one specific symbol size
let code = DataMatrix::encode(b"content to encode", SymbolSize::Square22);

// b) custom list of allowed symbol sizes
let code = DataMatrix::encode(
    b"content to encode",
    [SymbolSize::Square22, SymbolSize::Square26],
);

Implementations§

Source§

impl SymbolList

Source

pub fn with_extended_rectangles() -> Self

Get standard symbol sizes extended by all DMRE rectangles.

In ISO 21471 additional rectangular sizes are defined. Be aware that your decoder might not recognize these.

DMRE stands for Data Matrix Rectangular Extensions.

Source

pub fn enforce_square(self) -> Self

Remove all non-square symbols from the current selection.

Source

pub fn enforce_rectangular(self) -> Self

Remove all square symbols from the current selection.

Source

pub fn enforce_width_in<R: RangeBounds<usize>>(self, bounds: R) -> Self

Only keep symbols with width in the given range.

Source

pub fn enforce_height_in<R: RangeBounds<usize>>(self, bounds: R) -> Self

Only keep symbols with height in the given range.

Source

pub fn with_whitelist<I>(whitelist: I) -> Self
where I: IntoIterator<Item = SymbolSize>,

Create a symbol list containing only the given symbols.

The list does not need to be sorted.

Source

pub fn iter(&self) -> impl Iterator<Item = SymbolSize> + '_

Source

pub fn is_empty(&self) -> bool

Source

pub fn all() -> Self

Get a list with all supported symbol sizes.

Source

pub fn contains(&self, symbol_size: &SymbolSize) -> bool

Check if a symbol size is in this symbol list.

Trait Implementations§

Source§

impl Clone for SymbolList

Source§

fn clone(&self) -> SymbolList

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SymbolList

Source§

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

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

impl Default for SymbolList

Source§

fn default() -> Self

Create a symbol list with all but the DMRE symbol sizes.

Source§

impl Extend<SymbolSize> for SymbolList

Source§

fn extend<T>(&mut self, iter: T)
where T: IntoIterator<Item = SymbolSize>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<const N: usize> From<[SymbolSize; N]> for SymbolList

Source§

fn from(other: [SymbolSize; N]) -> SymbolList

Converts to this type from the input type.
Source§

impl From<SymbolSize> for SymbolList

Source§

fn from(size: SymbolSize) -> SymbolList

Converts to this type from the input type.
Source§

impl FromIterator<SymbolSize> for SymbolList

Source§

fn from_iter<T: IntoIterator<Item = SymbolSize>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl IntoIterator for SymbolList

Source§

type Item = SymbolSize

The type of the elements being iterated over.
Source§

type IntoIter = <BTreeSet<SymbolSize> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for SymbolList

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for SymbolList

Source§

impl StructuralPartialEq for SymbolList

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.