Struct datamatrix::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
sourceimpl 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) -> Self where
I: IntoIterator<Item = SymbolSize>,
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.
Panics
The call panics if the slice contains more elements than symbol sizes exist.
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
sourceimpl Clone for SymbolList
impl Clone for SymbolList
sourcefn clone(&self) -> SymbolList
fn clone(&self) -> SymbolList
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for SymbolList
impl Debug for SymbolList
sourceimpl Default for SymbolList
impl Default for SymbolList
sourceimpl Extend<SymbolSize> for SymbolList
impl Extend<SymbolSize> for SymbolList
sourcefn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = SymbolSize>,
fn extend<T>(&mut self, iter: T) where
T: IntoIterator<Item = SymbolSize>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<const N: usize> From<[SymbolSize; N]> for SymbolList
impl<const N: usize> From<[SymbolSize; N]> for SymbolList
sourcefn from(other: [SymbolSize; N]) -> SymbolList
fn from(other: [SymbolSize; N]) -> SymbolList
Performs the conversion.
sourceimpl From<SymbolSize> for SymbolList
impl From<SymbolSize> for SymbolList
sourcefn from(size: SymbolSize) -> SymbolList
fn from(size: SymbolSize) -> SymbolList
Performs the conversion.
sourceimpl FromIterator<SymbolSize> for SymbolList
impl FromIterator<SymbolSize> for SymbolList
sourcefn from_iter<T: IntoIterator<Item = SymbolSize>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = SymbolSize>>(iter: T) -> Self
Creates a value from an iterator. Read more
sourceimpl IntoIterator for SymbolList
impl IntoIterator for SymbolList
type Item = SymbolSize
type Item = SymbolSize
The type of the elements being iterated over.
type IntoIter = <BTreeSet<SymbolSize> as IntoIterator>::IntoIter
type IntoIter = <BTreeSet<SymbolSize> as IntoIterator>::IntoIter
Which kind of iterator are we turning this into?
sourceimpl PartialEq<SymbolList> for SymbolList
impl PartialEq<SymbolList> for SymbolList
sourcefn eq(&self, other: &SymbolList) -> bool
fn eq(&self, other: &SymbolList) -> bool
This method tests for self and other values to be equal, and is used
by ==. Read more
sourcefn ne(&self, other: &SymbolList) -> bool
fn ne(&self, other: &SymbolList) -> bool
This method tests for !=.
impl Eq for SymbolList
impl StructuralEq for SymbolList
impl StructuralPartialEq for SymbolList
Auto Trait Implementations
impl RefUnwindSafe for SymbolList
impl Send for SymbolList
impl Sync for SymbolList
impl Unpin for SymbolList
impl UnwindSafe for SymbolList
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more