### Data Matrix Pixel Rendering Example Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Example demonstrating how to iterate over the pixels of a Data Matrix bitmap to place rendering elements. ```rust let code = DataMatrix::encode(b"Foo", SymbolSize::Square10)?; for (x, y) in code.bitmap().pixels() { // place square/circle at (x, y) to render this Data Matrix } ``` -------------------------------- ### QR Code to Bitmap Conversion Example Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Demonstrates converting a QR code into a Bitmap for rendering, using the `qrcode2` crate. ```rust use qrcode2::{QrCode, Color}; let code = QrCode::new(b"Hello, World!!").unwrap(); let width = code.width(); let bits = code.into_colors().into_iter().map(|c| c == Color::Dark); let bitmap = Bitmap::new(bits, width); print!("{}", bitmap.unicode()); ``` -------------------------------- ### DataMatrix Encoding Example Source: https://docs.rs/datamatrix Demonstrates how to encode a simple string into a Data Matrix symbol and print its Unicode representation. ```APIDOC ## DataMatrix::encode ### Description Encodes a byte slice into a Data Matrix symbol. ### Method `encode` ### Parameters - `data`: `&[u8]` - The data to encode. - `symbol_list`: `SymbolList` - Specifies allowed symbol sizes. ### Returns - `Result` - A `DataMatrix` object if encoding is successful, otherwise an error. ### Usage Example ```rust let code = DataMatrix::encode( b"Hello, World!", SymbolList::default(), )?; print!("{}", code.bitmap().unicode()); ``` ``` -------------------------------- ### DataMatrix Decoding Example Source: https://docs.rs/datamatrix Shows how to decode a Data Matrix symbol from a pixel representation. ```APIDOC ## DataMatrix::decode ### Description Decodes a Data Matrix symbol from a pixel buffer. ### Method `decode` ### Parameters - `pixels`: `&[bool]` - A slice representing the pixels of the Data Matrix symbol (true for dark, false for light). - `width`: `usize` - The width of the pixel buffer. ### Returns - `Result<&[u8], DecodingError>` - A byte slice containing the decoded data if successful, otherwise a `DecodingError`. ### Usage Example ```rust // let pixels: Vec = … let width = 16; let data = DataMatrix::decode(&pixels, width)?; assert_eq!(&data, b"Hello, World!"); ``` ``` -------------------------------- ### DataMatrixBuilder Example with Encodation Types Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Demonstrates how to create a DataMatrixBuilder and specify allowed encodation types before encoding byte data. Ensure the `datamatrix` crate is imported. ```rust let datamatrix = DataMatrixBuilder::new() .with_encodation_types(EncodationType::Base256 | EncodationType::Edifact) .encode(b"\xFAaaa")?; Ok::<(), datamatrix::data::DataEncodingError>(()) ``` -------------------------------- ### DataMatrixBuilder::with_fnc1_start Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Specifies whether the Data Matrix should start with a `FNC1` codeword, marking it as a GS1 Data Matrix. ```APIDOC ## DataMatrixBuilder::with_fnc1_start ### Description Specify whether the Data Matrix shall start with a `FNC1` codeword marking it as a GS1 Data Matrix. ### Method `with_fnc1_start(self, fnc1_start: bool) -> Self` ### Parameters - `fnc1_start` (bool): `true` to start with FNC1, `false` otherwise. ### Returns - `Self`: The modified DataMatrixBuilder instance. ``` -------------------------------- ### Get Vector Path Drawing Instructions Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Computes a sequence of relative draw, move, and close instructions for rendering the bitmap as a vector path. The even-odd filling rule must be used. ```rust pub fn path(&self) -> Vec ``` -------------------------------- ### Bitmap::path Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Get vector path drawing instructions for this bitmap. This function computes a sequence of relative draw, relative move, and close instructions. The resulting path shows the bitmap if filled properly using the even-odd filling rule. ```APIDOC ## Bitmap::path ### Description Get vector path drawing instructions for this bitmap. This function computes a sequence of relative draw, relative move, and close instructions. The resulting path shows the bitmap if filled properly (see below). The coordinate system is identical to the one of the function pixels(). The starting position is not needed in this function because only relative coordinates are returned. ### §Filling rule The even-odd filling rule (as known in vector graphics) must be used. It is supported by many vector graphic formats, including SVG and PDF. ### §Example The `examples/` directory contains a SVG, EPS and PDF code example using this helper. ### §Implementation The outline is modeled as a graph which is then decomposed into Eulerian circuits. ### Method `pub fn path(&self) -> Vec` ``` -------------------------------- ### Get MatrixMap as Bitmap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Retrieves the content of the matrix as a Bitmap, with alignment patterns added. This provides a view of the matrix including necessary patterns for Data Matrix symbols. ```rust pub fn bitmap(&self) -> Bitmap ``` -------------------------------- ### Get Bitmap Height Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Returns the height of the bitmap, excluding any quiet zone. ```rust pub fn height(&self) -> usize ``` -------------------------------- ### Get Bitmap Width Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Returns the width of the bitmap, excluding any quiet zone. ```rust pub fn width(&self) -> usize ``` -------------------------------- ### Get All EncodationTypes Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.EncodationType.html Returns a FlagSet containing all defined encodation types. This is useful for operations that require considering all possible encoding schemes. ```rust pub fn all() -> FlagSet ``` -------------------------------- ### Iterate Over Black Pixels Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Provides an iterator over the coordinates (x, y) of the "black" pixels in the bitmap. The coordinate system starts at (0, 0) in the top-left corner. A quiet zone must be added during rendering. ```rust pub fn pixels(&self) -> impl Iterator + '_ ``` -------------------------------- ### impl Any for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides the `type_id` method to get the `TypeId` of an object. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response - **TypeId**: The unique identifier for the type of `self`. ``` -------------------------------- ### Encode with SymbolList restrictions Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Use SymbolList to enforce specific symbol dimensions and types for encoding. This example restricts encoding to rectangular symbols with a maximum height of 20. ```rust let code = DataMatrix::encode( b"Hello, World!", SymbolList::with_extended_rectangles() .enforce_rectangular() .enforce_height_in(..=20), ); ``` -------------------------------- ### Get EncodationType Index Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.EncodationType.html Retrieves a fixed numerical index for an encodation type, ranging from 0 to 5. This index also reflects the preference order of encodation types, with lower numbers indicating higher preference. ```rust pub fn index(&self) -> usize ``` -------------------------------- ### Get Type ID Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Gets the `TypeId` of the current type. This is a generic method from the `Any` trait. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### DataMatrixBuilder::new Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Initializes a new instance of the DataMatrixBuilder. ```APIDOC ## DataMatrixBuilder::new ### Description Initializes a new instance of the DataMatrixBuilder. ### Method `new()` ### Returns - `Self`: A new DataMatrixBuilder instance. ``` -------------------------------- ### Bitmap::new Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Create a new Bitmap. This allows you to use the rendering helpers also for other structures like QR codes. ```APIDOC ## Bitmap::new ### Description Create a new Bitmap. This allows you to use the rendering helpers also for, say, QR codes. ### Method `pub fn new(bits: T, width: usize) -> Self` ### Type Parameters * `T`: An iterator that yields items of type `B`. * `B`: The type representing a single bit. ### Parameters * `bits`: An iterator providing the bitmap data. * `width`: The width of the bitmap. ### Panics Panics if `width` is zero or does not evenly divide the number of bits returned by `bits`. ### Example ```rust use qrcode2::{QrCode, Color}; let code = QrCode::new(b"Hello, World!!").unwrap(); let width = code.width(); let bits = code.into_colors().into_iter().map(|c| c == Color::Dark); let bitmap = Bitmap::new(bits, width); print!("{}", bitmap.unicode()); ``` ``` -------------------------------- ### impl CloneToUninit for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides an experimental, nightly-only method for unsafe copy-assignment to uninitialized memory. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description 🔬This is a nightly-only experimental API. (`clone_to_uninit`) Performs copy-assignment from `self` to `dest`. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters - **dest** (*mut u8) - Required - A raw pointer to the destination memory. ### Request Example None ### Response None (This is an unsafe operation with no direct return value.) ``` -------------------------------- ### Create New Bitmap Instance Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Creates a new Bitmap instance from an iterator of bits and a specified width. Panics if width is zero or does not evenly divide the number of bits. ```rust pub fn new(bits: T, width: usize) -> Self where T: IntoIterator, ``` -------------------------------- ### impl From for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides a trivial implementation of `From` for `T`, returning the argument unchanged. ```APIDOC ## fn from(t: T) -> T ### Description Returns the argument unchanged. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters - **t** (T) - Required - The value to be converted. ### Request Example None ### Response #### Success Response - **T**: The original value `t`. ``` -------------------------------- ### clone_from Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Performs copy-assignment from a source DataMatrixBuilder. ```APIDOC ## fn clone_from(&mut self, source: &Self) ### Description Performs copy-assignment from `source`. ### Method `clone_from` ### Parameters - `self`: A mutable reference to the DataMatrixBuilder instance. - `source`: A reference to the source DataMatrixBuilder instance. ``` -------------------------------- ### Create New MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Creates a new, empty matrix for a given symbol size. This is the primary constructor for an empty MatrixMap. ```rust pub fn new(size: SymbolSize) -> Self ``` -------------------------------- ### Clone to Uninitialized Memory (Nightly) Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Performs copy-assignment from `self` to uninitialized memory at `dest`. This is a nightly-only experimental API. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### fmt Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Formats the DataMatrixBuilder value using the given formatter. ```APIDOC ## fn fmt(&self, f: &mut Formatter<'_>) -> Result ### Description Formats the value using the given formatter. ### Method `fmt` ### Parameters - `self`: A reference to the DataMatrixBuilder instance. - `f`: A mutable reference to the formatter. ``` -------------------------------- ### DataMatrixBuilder::with_macros Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Determines whether to use macros. This is enabled by default. ```APIDOC ## DataMatrixBuilder::with_macros ### Description Whether to use macros or not. This is enabled by default. ### Method `with_macros(self, use_macros: bool) -> Self` ### Parameters - `use_macros` (bool): `true` to enable macros, `false` otherwise. ### Returns - `Self`: The modified DataMatrixBuilder instance. ``` -------------------------------- ### Bitmap::pixels Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Get an iterator over the “black” pixels’ coordinates (x, y). A black pixel refers to one of the tiny black squares a Data Matrix is usually made of. Depending on your target, such a pixel may be rendered using multiple image pixels, or whatever you use to visualize the Data Matrix. ```APIDOC ## Bitmap::pixels ### Description Get an iterator over the “black” pixels’ coordinates `(x, y)`. A black pixel refers to one of the tiny black squares a Data Matrix is usually made of. Depending on your target, such a pixel may be rendered using multiple image pixels, or whatever you use to visualize the Data Matrix. The coordinate system is centered in the top left corner starting in `(0, 0)` with a horizontal x-axis and vertical y-axis. The pixels are returned in order, incrementing x before y. A quiet zone is not included in the coordinates but one must be added when rendering: The minimum free space required around the Data Matrix has to have the width/height of one “black” pixel. The quiet zone should have the background’s color. A Data Matrix can be either rendered using dark color on a light background, or the other way around. More details on contrast, size, etc. can be found in the referenced standards mentioned in the specification. ### Method `pub fn pixels(&self) -> impl Iterator + '_` ### Example ```rust let code = DataMatrix::encode(b"Foo", SymbolSize::Square10)?; for (x, y) in code.bitmap().pixels() { // place square/circle at (x, y) to render this Data Matrix } ``` ``` -------------------------------- ### DataMatrixBuilder::with_symbol_list Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Specifies the list of allowed symbol sizes. Uses `SymbolList::default()` by default. ```APIDOC ## DataMatrixBuilder::with_symbol_list ### Description Specify the list of allowed symbols sizes. Uses `SymbolList::default()` by default. ### Method `with_symbol_list>(self, symbol_list: I) -> Self` ### Parameters - `symbol_list` (I): A type that can be converted into a `SymbolList`. ### Returns - `Self`: The modified DataMatrixBuilder instance. ``` -------------------------------- ### default Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Returns the default value for DataMatrixBuilder. ```APIDOC ## fn default() -> Self ### Description Returns the “default value” for a type. ### Method `default` ### Parameters None. ``` -------------------------------- ### Try Convert From Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Performs the conversion from a source type `U` to the target type `T`. The conversion might fail, returning a `Result`. This is a generic method from the `TryFrom` trait. ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### Try Convert Into Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Performs the conversion from the source type `T` to the target type `U`. The conversion might fail, returning a `Result`. This is a generic method from the `TryInto` trait. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Create MatrixMap with Codewords Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Creates a MatrixMap specifically for boolean bits and fills it with provided codewords. This is a specialized constructor for boolean matrices. ```rust pub fn new_with_codewords(data: &[u8], symbol_size: SymbolSize) -> Self ``` -------------------------------- ### DataMatrix::bitmap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Creates an abstract bitmap representation of the Data Matrix. ```APIDOC ## DataMatrix::bitmap ### Description Create an abstract bitmap representing the Data Matrix. ### Signature `pub fn bitmap(&self) -> Bitmap` ### Returns - `Bitmap` - An abstract bitmap representation of the Data Matrix. ``` -------------------------------- ### DataMatrixBuilder Encode Byte Slice Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Encodes a byte slice into a Data Matrix symbol. The builder can automatically select the smallest fitting symbol size up to a certain limit. Ensure the `datamatrix` crate is imported. ```rust let datamatrix = DataMatrixBuilder::new().encode(b"some data")?; ``` -------------------------------- ### Create From Value Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Returns the argument unchanged. This is a generic implementation of the `From` trait. ```rust fn from(t: T) -> T ``` -------------------------------- ### Create MatrixMap from Bitmap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Reads data from a bitmap to create a MatrixMap. The input `bits` must represent a rectangular image in row-major order, including alignment patterns. ```rust pub fn try_from_bits( bits: &[M], width: usize, ) -> Result<(Self, SymbolSize), BitmapConversionError> where M: PartialEq, ``` -------------------------------- ### Compute Encodation Plan with All Modes Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/fn.encodation_plan.html Calculates an encodation plan using all available encodation types. This is useful for finding the most compact encoding for a given data string and symbol size. ```rust encodation_plan(b"Hello!", &SymbolList::default(), EncodationType::all()); ``` -------------------------------- ### Write Padding to MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Writes a 4x4 padding pattern to the lower-right corner of the matrix if it is needed. This is an in-place modification. ```rust pub fn write_padding(&mut self) ``` -------------------------------- ### encodation_plan Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/fn.encodation_plan.html Computes a plan for when to switch encodation types during data encoding. It returns `None` if the data does not fit into the symbol size, otherwise it returns a vector of tuples indicating mode switches for minimal encoding size. ```APIDOC ## encodation_plan ### Description Compute a plan for when to switch encodation types during data encoding. Returns `None` if the `data` does not fit into the given `symbol_size`. Otherwise the function returns a vector of tuples `(usize, EncodationType)` which describe when to switch the mode. The first entry of the tuple is the number of input characters left at the point of the planned mode switch. For example, `(20, EncodationType::C40)` would mean that the mode shall be switched to C40 when only 20 characters remain to encode. The plan is chosen to obtain a minimal encoding size. If there are multiple solutions, a plan is picked by first filtering by the “complexity” of the modes, and then by the number of mode switches. If there is still more than one possibility the returned plan is an implementation detail. ### Parameters * `data` (&[u8]): The input data to encode. * `symbol_list` (&SymbolList): The list of available symbol sizes. * `enabled_modes` (impl Into>): The encodation modes that are enabled. ### Returns * `Option>`: `None` if the data does not fit, otherwise a vector of tuples `(usize, EncodationType)` indicating mode switches. ### Example ```rust encodation_plan(b"Hello!", &SymbolList::default(), EncodationType::all()); encodation_plan(b"Hello!", &SymbolList::default(), EncodationType::Ascii | EncodationType::Edifact); ``` ``` -------------------------------- ### MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Provides core functionalities for MatrixMap, generic over the bit type B. ```APIDOC ## MatrixMap ### Description Core functionalities for MatrixMap, generic over the bit type B. ### Methods #### `new(size: SymbolSize) -> Self` Create a new, empty matrix for the given symbol size. #### `try_from_bits(bits: &[M], width: usize) -> Result<(Self, SymbolSize), BitmapConversionError>` Read the data from a bitmap. The argument `bits` shall represent a rectangular image, enumerated starting from the top left corner in row-major order. The alignment patterns must be included. #### `write_padding(&mut self)` Write a 4x4 padding pattern in the lower right corner if needed. #### `bitmap(&self) -> Bitmap` Get the content of the matrix as a bitmap with alignment patterns added. #### `traverse_mut(&mut self, visit_fn: F)` Traverse the symbol in codeword order and call the function for each position. The codeword index is given as the first argument to `visit`. The second argument of `visit` contains the bits of the codewords, most significant first. #### `traverse(&self, visit_fn: F)` Nonmutable version of traverse_mut. ``` -------------------------------- ### DataMatrix::data_codewords Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Retrieves only the data codewords, which is a prefix of the full codewords returned by `codewords()`. ```APIDOC ## DataMatrix::data_codewords ### Description Get the codewords that encode the data. This is a prefix of the codewords returned by codewords(). ### Signature `pub fn data_codewords(&self) -> &[u8]` ### Returns - `&[u8]` - A slice of bytes representing the data codewords. ``` -------------------------------- ### clone Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Returns a duplicate of the DataMatrixBuilder value. ```APIDOC ## fn clone(&self) -> DataMatrixBuilder ### Description Returns a duplicate of the DataMatrixBuilder value. ### Method `clone` ### Parameters - `self`: A reference to the DataMatrixBuilder instance. ``` -------------------------------- ### impl TryFrom for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides a mechanism for attempting to convert type `U` into type `T`, returning a `Result`. ```APIDOC ## fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters - **value** (U) - Required - The value to attempt to convert. ### Request Example None ### Response #### Success Response - **Result** - Ok(T) if the conversion is successful, Err(Error) otherwise. ``` -------------------------------- ### Bitmap Struct Definition Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Defines the abstract Bitmap struct. It contains private fields and offers helpers for rendering content. ```rust pub struct Bitmap { /* private fields */ } ``` -------------------------------- ### DataMatrixBuilder Encode String Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Encodes a string into a Data Matrix symbol. If the string contains non-Latin-1 characters, a UTF-8 ECI header is prepended. Ensure the `datamatrix` crate is imported. ```rust let datamatrix = DataMatrixBuilder::new().encode_str("some string")?; ``` -------------------------------- ### impl TryInto for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides a mechanism for attempting to convert type `T` into type `U`, returning a `Result`. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response - **Result** - Ok(U) if the conversion is successful, Err(Error) otherwise. ``` -------------------------------- ### DataMatrix::encode Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Encodes arbitrary data into a Data Matrix (ECC200). This is a wrapper for `DataMatrixBuilder::encode`. ```APIDOC ## DataMatrix::encode ### Description Encode data as a Data Matrix (ECC200). This is a wrapper for DataMatrixBuilder::encode. ### Signature `pub fn encode>( data: &[u8], symbol_list: I, ) -> Result` ### Parameters #### Path Parameters - `data` (&[u8]) - Required - The data to encode. - `symbol_list` (I: Into) - Required - A type that can be converted into a `SymbolList`. ### Returns - `Result` - A Result containing the encoded DataMatrix or a DataEncodingError. ``` -------------------------------- ### Compute Encodation Plan with Specific Modes Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/fn.encodation_plan.html Calculates an encodation plan using only ASCII and EDIFACT encodation types. This is useful when you want to restrict the encoding to a subset of available modes. ```rust encodation_plan(b"Hello!", &SymbolList::default(), EncodationType::Ascii | EncodationType::Edifact); ``` -------------------------------- ### Encode Data to Data Codewords Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/fn.encode_data.html Use this function to convert raw data into Data Matrix codewords. It requires the data, symbol specifications, an optional ECI value, and enabled encodation modes. The function returns the encoded data and the determined symbol size. ```rust pub fn encode_data( data: &[u8], symbol_list: &SymbolList, eci: Option, enabled_modes: impl Into>, use_macros: bool, ) -> Result<(Vec, SymbolSize), DataEncodingError> ``` -------------------------------- ### Compare MatrixMap for Equality Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Tests if two MatrixMap instances are equal. This implementation is part of the `PartialEq` trait and is used by the `==` operator. ```rust fn eq(&self, other: &MatrixMap) -> bool ``` -------------------------------- ### Bitmap::unicode Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Compute a unicode representation (“ASCII art”). This is intended as a demo functionality and might look weird if the line height is wrong or if you are not using a monospaced font. ```APIDOC ## Bitmap::unicode ### Description Compute a unicode representation (“ASCII art”). This is intended as a demo functionality. It might look weird if the line height is wrong or if you are not using a monospaced font. ### Method `pub fn unicode(&self) -> String` ``` -------------------------------- ### Bitmap::width Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Return the width of the bitmap (no quiet zone included). ```APIDOC ## Bitmap::width ### Description Return the width of the bitmap (no quiet zone included). ### Method `pub fn width(&self) -> usize` ``` -------------------------------- ### MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Specific implementations for MatrixMap when the bit type is bool. ```APIDOC ## MatrixMap ### Description Specific implementations for MatrixMap when the bit type is bool. ### Methods #### `new_with_codewords(data: &[u8], symbol_size: SymbolSize) -> Self` Create a MatrixMap and fills with codewords. #### `codewords(&self) -> Vec` Extract the codewords. This includes the error correction codewords. ``` -------------------------------- ### Compare MatrixMap for Inequality Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Tests if two MatrixMap instances are not equal. This implementation is part of the `PartialEq` trait and is used by the `!=` operator. ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Compute Unicode Representation Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Computes a Unicode string representation of the bitmap, intended for demonstration. May appear distorted with non-monospaced fonts or incorrect line heights. ```rust pub fn unicode(&self) -> String ``` -------------------------------- ### eq Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Tests if two DataMatrixBuilder values are equal. ```APIDOC ## fn eq(&self, other: &DataMatrixBuilder) -> bool ### Description Tests for `self` and `other` values to be equal, and is used by `==`. ### Method `eq` ### Parameters - `self`: A reference to the first DataMatrixBuilder instance. - `other`: A reference to the second DataMatrixBuilder instance. ``` -------------------------------- ### Bitmap::height Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.Bitmap.html Return the height of the bitmap (no quiet zone included). ```APIDOC ## Bitmap::height ### Description Return the height of the bitmap (no quiet zone included). ### Method `pub fn height(&self) -> usize` ``` -------------------------------- ### impl BorrowMut for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Enables mutable borrowing of an object. ```APIDOC ## fn borrow_mut(&mut self) -> &mut T ### Description Mutably borrows from an owned value. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response - **&mut T**: A mutable reference to the borrowed value. ``` -------------------------------- ### Clone From MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Performs copy-assignment from a source MatrixMap to the current one. This method is part of the `Clone` trait implementation. ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Encode with specific SymbolSize or list Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Encode data using either a single, specific symbol size or a custom list of allowed symbol sizes. This is useful when precise control over the output symbol dimensions is required. ```rust // a) use one specific symbol size let code = DataMatrix::encode(b"content to encode", SymbolSize::Square22); ``` ```rust // b) custom list of allowed symbol sizes let code = DataMatrix::encode( b"content to encode", [SymbolSize::Square22, SymbolSize::Square26], ); ``` -------------------------------- ### impl Borrow for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Enables immutable borrowing of an object. ```APIDOC ## fn borrow(&self) -> &T ### Description Immutably borrows from an owned value. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response - **&T**: An immutable reference to the borrowed value. ``` -------------------------------- ### DataMatrixBuilder::encode Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Encodes data as a Data Matrix (ECC200). The encoder can automatically pick the smallest size that fits the data, but there is an upper limit. ```APIDOC ## DataMatrixBuilder::encode ### Description Encode data as a Data Matrix (ECC200). Please read the module documentation for some charset notes. If you did that and your input can be represented with the Latin 1 charset you may use the conversion function in the data module. If you only use printable ASCII you can just pass the data as is. If the data does not fit into the given size encoding will fail. The encoder can automatically pick the smallest size which fits the data (see SymbolList) but there is an upper limit. ### Method `encode(self, data: &[u8]) -> Result` ### Parameters - `data` (&[u8]): The byte slice containing the data to encode. ### Returns - `Result`: A `DataMatrix` object if encoding is successful, or a `DataEncodingError` otherwise. ``` -------------------------------- ### SymbolSize Trait Implementations Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.SymbolSize.html This section outlines the auto and blanket trait implementations for the SymbolSize enum. These implementations define fundamental behaviors and interoperability with other types. ```APIDOC ## SymbolSize Enum Documentation This document details the `SymbolSize` enum and its associated trait implementations. ### Auto Trait Implementations The `SymbolSize` enum automatically implements the following traits: - `Freeze` - `RefUnwindSafe` - `Send` - `Sync` - `Unpin` - `UnsafeUnpin` - `UnwindSafe` ### Blanket Implementations The `SymbolSize` enum also benefits from blanket implementations for several generic traits: - **`Any`**: Provides runtime type information. - `fn type_id(&self) -> TypeId`: Gets the `TypeId` of the instance. - **`Borrow`**: Allows immutable borrowing. - `fn borrow(&self) -> &T`: Immutably borrows the value. - **`BorrowMut`**: Allows mutable borrowing. - `fn borrow_mut(&mut self) -> &mut T`: Mutably borrows the value. - **`CloneToUninit`** (Nightly-only experimental): - `unsafe fn clone_to_uninit(&self, dest: *mut u8)`: Performs copy-assignment to an uninitialized memory location. - **`From`**: Enables conversion from a type `T` to itself. - `fn from(t: T) -> T`: Returns the argument unchanged. - **`Into`**: Enables conversion into another type `U` if `U` implements `From`. - `fn into(self) -> U`: Converts the value into type `U`. - **`ToOwned`**: Facilitates creating owned data from borrowed data. - `type Owned = T`: Specifies the owned type. - `fn to_owned(&self) -> T`: Creates an owned version, usually by cloning. - `fn clone_into(&self, target: &mut T)`: Clones the borrowed data into a mutable target. - **`TryFrom`**: Enables fallible conversion from type `U` to `T`. - `type Error = Infallible`: Defines the error type for conversion failures. - `fn try_from(value: U) -> Result>::Error>`: Attempts the conversion. - **`TryInto`**: Enables fallible conversion from type `T` to `U`. - `type Error = >::Error`: Defines the error type for conversion failures. - `fn try_into(self) -> Result>::Error>`: Attempts the conversion. ``` -------------------------------- ### impl Into for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides a generic implementation for converting type `T` into type `U` if `U` implements `From`. ```APIDOC ## fn into(self) -> U ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response - **U**: The converted value of type `U`. ``` -------------------------------- ### ne Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Tests if two DataMatrixBuilder values are not equal. ```APIDOC ## fn ne(&self, other: &Rhs) -> bool ### Description Tests for `!=`. ### Method `ne` ### Parameters - `self`: A reference to the first DataMatrixBuilder instance. - `other`: A reference to the second DataMatrixBuilder instance. ``` -------------------------------- ### DataMatrix::codewords Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Retrieves the data in its encoded form, including error correction. For only the data codewords, use `data_codewords()`. ```APIDOC ## DataMatrix::codewords ### Description Get the data in encoded form. Error correction is included. See data_codewords() if you only need the data. ### Signature `pub fn codewords(&self) -> &[u8]` ### Returns - `&[u8]` - A slice of bytes representing the encoded Data Matrix codewords. ``` -------------------------------- ### DataMatrix Struct Definition Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Defines the DataMatrix struct, which holds the size of the encoded Data Matrix. ```rust pub struct DataMatrix { pub size: SymbolSize, /* private fields */ } ``` -------------------------------- ### Clone Implementation for EncodationType Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.EncodationType.html Provides methods for cloning EncodationType values. This allows creating copies of encodation type instances. ```rust fn clone(&self) -> EncodationType; fn clone_from(&mut self, source: &Self); ``` -------------------------------- ### EncodationType Blanket Implementations Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/enum.EncodationType.html This section details the blanket implementations available for the EncodationType enum, showcasing its compatibility with various standard Rust traits. ```APIDOC ## Blanket Implementations ### impl Any for T where T: 'static + ?Sized, #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ### impl Borrow for T where T: ?Sized, #### fn borrow(&self) -> &T Immutably borrows from an owned value. ### impl BorrowMut for T where T: ?Sized, #### fn borrow_mut(&mut self) -> &mut T Mutably borrows from an owned value. ### impl CloneToUninit for T where T: Clone, #### unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. ### impl From for T #### fn from(t: T) -> T Returns the argument unchanged. ### impl Into for T where U: From, #### fn into(self) -> U Calls `U::from(self)`. ### impl ToOwned for T where T: Clone, #### type Owned = T The resulting type after obtaining ownership. #### fn to_owned(&self) -> T Creates owned data from borrowed data, usually by cloning. #### fn clone_into(&self, target: &mut T) Uses borrowed data to replace owned data, usually by cloning. ### impl TryFrom for T where U: Into, #### type Error = Infallible The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> Performs the conversion. ### impl TryInto for T where U: TryFrom, #### type Error = >::Error The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Bit Trait Implementations for bool Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/trait.Bit.html Provides implementations for the Bit trait on the bool type, defining LOW as false and HIGH as true. ```rust const LOW: bool = false ``` ```rust const HIGH: bool = true ``` -------------------------------- ### Encode Text to Data Matrix Source: https://docs.rs/datamatrix Encodes a byte string into a Data Matrix symbol and prints its Unicode bitmap representation. Allows specifying symbol sizes for custom output. ```rust let code = DataMatrix::encode( b"Hello, World!", SymbolList::default(), )?; print!("{}", code.bitmap().unicode()); ``` -------------------------------- ### DataMatrix::encode_str Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Encodes a string slice into a Data Matrix (ECC200). This is a wrapper for `DataMatrixBuilder::encode_str`. ```APIDOC ## DataMatrix::encode_str ### Description Encode a string as a Data Matrix (ECC200). This is a wrapper for DataMatrixBuilder::encode_str. ### Signature `pub fn encode_str>( text: &str, symbol_list: I, ) -> Result` ### Parameters #### Path Parameters - `text` (&str) - Required - The string to encode. - `symbol_list` (I: Into) - Required - A type that can be converted into a `SymbolList`. ### Returns - `Result` - A Result containing the encoded DataMatrix or a DataEncodingError. ``` -------------------------------- ### impl ToOwned for T Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.SymbolList.html Provides methods for creating owned data from borrowed data. ```APIDOC ## fn to_owned(&self) -> T ### Description Creates owned data from borrowed data, usually by cloning. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response - **T**: An owned version of the data. ``` ```APIDOC ## fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters - **target** (&mut T) - Required - A mutable reference to the owned data to be updated. ### Request Example None ### Response None (This method modifies the `target` in place.) ``` -------------------------------- ### encodation_plan Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/index.html Compute a plan for when to switch encodation types during data encoding. This function is intended for lower-level operations and may not be directly called by end-users. ```APIDOC ## encodation_plan ### Description Compute a plan for when to switch encodation types during data encoding. ### Note There is no reason I can think of for an end user of the library to ever call them directly but they can be useful if one needs to work on a lower level. ``` -------------------------------- ### Decode Data Matrix Codewords to String Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/fn.decode_str.html Use this function to decode byte slices containing Data Matrix data codewords into a String. It handles ECI and defaults to latin1 encoding if no ECI is present. ```rust pub fn decode_str(data: &[u8]) -> Result ``` -------------------------------- ### Partial Equality for EncodationType Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.EncodationType.html Implements partial equality comparison for EncodationType variants. This allows checking if two encodation types are equal using the `==` operator. ```rust fn eq(&self, other: &EncodationType) -> bool; fn ne(&self, other: &Rhs) -> bool; ``` -------------------------------- ### Into Value Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Calls `U::from(self)`. The conversion behavior is determined by the `From for U` implementation. This is a generic method from the `Into` trait. ```rust fn into(self) -> U ``` -------------------------------- ### Clone MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Returns a duplicate of the MatrixMap. This implementation requires the bit type `B` to implement the `Clone` trait. ```rust fn clone(&self) -> MatrixMap ``` -------------------------------- ### Format MatrixMap for Debugging Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Formats the MatrixMap value using the given formatter. This implementation is part of the `Debug` trait and is useful for debugging. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### DataMatrix::encode_gs1 Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Encodes data as a GS1 Data Matrix. It adds the `FNC1` codeword in the first position. Encoding `FNC1` in later positions is not currently implemented. ```APIDOC ## DataMatrix::encode_gs1 ### Description Encode data as a GS1 Data Matrix. The only difference to encode() is that the `FNC1` codeword is added in the first position. Encoding `FNC1` in later positions is not implemented as of now. ### Signature `pub fn encode_gs1>( data: &[u8], symbol_list: I, ) -> Result` ### Parameters #### Path Parameters - `data` (&[u8]) - Required - The data to encode. - `symbol_list` (I: Into) - Required - A type that can be converted into a `SymbolList`. ### Request Example ```rust // use "\x1D" (ASCII GS control sequence) to concatenate element strings let data = b"01034531200000111719112510ABCD1234\x1D2110"; let data_matrix = DataMatrix::encode_gs1(data, SymbolList::default())?; let bitmap = data_matrix.bitmap(); ``` ### Returns - `Result` - A Result containing the encoded GS1 DataMatrix or a DataEncodingError. ``` -------------------------------- ### DataMatrixBuilder::encode_str Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Encodes a string as a Data Matrix (ECC200). If the string can be converted to Latin-1, no ECI is used; otherwise, an initial UTF8 ECI is inserted. ```APIDOC ## DataMatrixBuilder::encode_str ### Description Encodes a string as a Data Matrix (ECC200). If the string can be converted to Latin-1, no ECI is used, otherwise an initial UTF8 ECI is inserted. Please check if your decoder has support for that. See the notes on the module documentation for more details. ### Method `encode_str(self, text: &str) -> Result` ### Parameters - `text` (&str): The string to encode. ### Returns - `Result`: A `DataMatrix` object if encoding is successful, or a `DataEncodingError` otherwise. ``` -------------------------------- ### Encode GS1 Data Matrix Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrix.html Encodes data into a GS1 Data Matrix. The FNC1 codeword is added in the first position. This is a wrapper for DataMatrixBuilder::encode_gs1. ```rust // use "\x1D" (ASCII GS control sequence) to concatenate element strings let data = b"01034531200000111719112510ABCD1234\x1D2110"; let data_matrix = DataMatrix::encode_gs1(data, SymbolList::default())?; let bitmap = data_matrix.bitmap(); ``` -------------------------------- ### Immutably Traverse MatrixMap Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Provides a non-mutable version of `traverse_mut`. It traverses the symbol in codeword order and calls a provided function for each position without allowing modifications. ```rust pub fn traverse(&self, visit_fn: F) where F: FnMut(usize, [M; 8]), ``` -------------------------------- ### Compute Reed-Solomon Error Correction Codes Source: https://docs.rs/datamatrix/0.3.3/datamatrix/errorcode/fn.encode_error.html Use this function to compute the Reed-Solomon error correction codes for Data Matrix symbols. It panics if the input data size is incorrect for the specified symbol size. ```rust pub fn encode_error(data: &[u8], size: SymbolSize) -> Vec ``` -------------------------------- ### Convert Latin 1 to UTF-8 Source: https://docs.rs/datamatrix/0.3.3/datamatrix/data/fn.latin1_to_utf8.html Converts a Latin 1 encoded byte slice to a UTF-8 string. Returns None if the input contains invalid Latin 1 characters. ```rust pub fn latin1_to_utf8(latin1: &[u8]) -> Option ``` -------------------------------- ### DataMatrixBuilder::with_encodation_types Source: https://docs.rs/datamatrix/0.3.3/datamatrix/struct.DataMatrixBuilder.html Specifies which encodation types can be used for the Data Matrix. By default, all encodation types are enabled. ```APIDOC ## DataMatrixBuilder::with_encodation_types ### Description Specify which encodation can be used. By default all encodation types are enabled. ### Method `with_encodation_types(self, types: impl Into>) -> Self` ### Parameters - `types` (FlagSet): The encodation types to enable. ### Returns - `Self`: The modified DataMatrixBuilder instance. ### Example ```rust let datamatrix = DataMatrixBuilder::new() .with_encodation_types(EncodationType::Base256 | EncodationType::Edifact) .encode(b"\xFAaaa")?; Ok::<(), datamatrix::data::DataEncodingError>(()) ``` ``` -------------------------------- ### Rect26x40 Variant Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.SymbolSize.html Represents the 26x40 module rectangular symbol size for Data Matrix. ```rust Rect26x40 ``` -------------------------------- ### Clone Into Source: https://docs.rs/datamatrix/0.3.3/datamatrix/placement/struct.MatrixMap.html Uses borrowed data to replace owned data, usually by cloning. This is a generic method from the `ToOwned` trait. ```rust fn clone_into(&self, target: &mut T) ``` -------------------------------- ### Rect20x64 Variant Source: https://docs.rs/datamatrix/0.3.3/datamatrix/enum.SymbolSize.html Represents the 20x64 module rectangular symbol size for Data Matrix. ```rust Rect20x64 ```