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
impl SymbolList
Sourcepub fn with_extended_rectangles() -> Self
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.
Sourcepub fn enforce_square(self) -> Self
pub fn enforce_square(self) -> Self
Remove all non-square symbols from the current selection.
Sourcepub fn enforce_rectangular(self) -> Self
pub fn enforce_rectangular(self) -> Self
Remove all square symbols from the current selection.
Sourcepub fn enforce_width_in<R: RangeBounds<usize>>(self, bounds: R) -> Self
pub fn enforce_width_in<R: RangeBounds<usize>>(self, bounds: R) -> Self
Only keep symbols with width in the given range.
Sourcepub fn enforce_height_in<R: RangeBounds<usize>>(self, bounds: R) -> Self
pub fn enforce_height_in<R: RangeBounds<usize>>(self, bounds: R) -> Self
Only keep symbols with height in the given range.
Sourcepub fn with_whitelist<I>(whitelist: I) -> Selfwhere
I: IntoIterator<Item = SymbolSize>,
pub fn with_whitelist<I>(whitelist: I) -> Selfwhere
I: IntoIterator<Item = SymbolSize>,
Create a symbol list containing only the given symbols.
The list does not need to be sorted.
pub fn iter(&self) -> impl Iterator<Item = SymbolSize> + '_
pub fn is_empty(&self) -> bool
Sourcepub fn contains(&self, symbol_size: &SymbolSize) -> bool
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
impl Clone for SymbolList
Source§fn clone(&self) -> SymbolList
fn clone(&self) -> SymbolList
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for SymbolList
impl Debug for SymbolList
Source§impl Default for SymbolList
impl Default for SymbolList
Source§impl Extend<SymbolSize> for SymbolList
impl Extend<SymbolSize> for SymbolList
Source§fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = SymbolSize>,
fn extend<T>(&mut self, iter: T)where
T: IntoIterator<Item = SymbolSize>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)