qrkit
Public API for the qrkit package.
Types
Type alias for qrkit/error.EncodeError.
To pattern-match on EmptyInput | InvalidVersion(..) | InvalidEciDesignator(..) | DataExceedsCapacity(..) | UnsupportedCharacter(..) | IncompatibleOptions(..), import qrkit/error.
pub type EncodeError =
error.EncodeError
Type alias for qrkit/types.ErrorCorrection.
To pattern-match on Low | Medium | Quartile | High, import qrkit/types.
pub type ErrorCorrection =
types.ErrorCorrection
Type alias for qrkit/error.MatrixAccessError.
To pattern-match on ModuleOutOfBounds(..), import qrkit/error.
pub type MatrixAccessError =
error.MatrixAccessError
Type alias for qrkit/types.Mode.
To pattern-match on Numeric | Alphanumeric | Byte | Kanji, import qrkit/types.
pub type Mode =
types.Mode
Type alias for qrkit/types.ModePreference.
To pattern-match on Auto | ForceByte, import qrkit/types.
pub type ModePreference =
types.ModePreference
Type alias for qrkit/types.Symbol.
To pattern-match on Standard | Micro | Rectangular, import qrkit/types.
pub type Symbol =
types.Symbol
Values
pub fn build(
builder: Builder,
) -> Result(QrCode, error.EncodeError)
Build a QR code from the accumulated builder configuration.
pub fn encode(data: String) -> Result(QrCode, error.EncodeError)
Encode input text using the default builder configuration.
pub fn encode_split(
data: String,
max_version: Int,
) -> Result(List(QrCode), error.EncodeError)
Split data into multiple symbols using Structured Append (ISO/IEC 18004 §8.2).
Each returned QR carries the 20-bit Structured Append header so a compliant
reader can reassemble the original message. When data fits in a single QR
at max_version, the returned list contains exactly one symbol with no SA
header. Uses the Medium error correction level — call encode_split_with
for a different level.
pub fn encode_split_with(
data: String,
max_version: Int,
ecc: types.ErrorCorrection,
) -> Result(List(QrCode), error.EncodeError)
Same as encode_split but with a caller-chosen error correction level.
pub fn error_correction(qr: QrCode) -> types.ErrorCorrection
Return the error correction level used by this symbol.
pub fn error_correction_designator(
ecc: types.ErrorCorrection,
) -> String
Return the canonical single-letter ECC designator.
pub fn mask(qr: QrCode) -> Int
Return the mask pattern that was applied. Standard QR returns 0..7, Micro QR 0..3, and rMQR always 4 (rMQR uses a single fixed mask).
pub fn module_at(
qr: QrCode,
x: Int,
y: Int,
) -> Result(Bool, error.MatrixAccessError)
Return a single module from the symbol matrix.
Returns Error(ModuleOutOfBounds(..)) when x or y fall outside the
matrix dimensions.
pub fn size(qr: QrCode) -> Int
Return the symbol side length in modules. For non-square rMQR symbols this
is the width; use width and height for the explicit dimensions.
pub fn symbol_size(qr: QrCode) -> #(Int, Int)
Return the symbol dimensions in modules.
pub fn version(qr: QrCode) -> Int
Return the symbol version number. Standard QR returns 1..40, Micro QR 1..4 (M1..M4), and rMQR 1..32 (R7x43..R17x139).
pub fn with_ecc(
builder: Builder,
ecc: types.ErrorCorrection,
) -> Builder
Set the desired error correction level.
pub fn with_eci(builder: Builder, designator: Int) -> Builder
Add an optional ECI assignment designator before the data segments.
ECI is only supported for Standard QR. Valid designators are in the range
0..999999; invalid values surface as Error(InvalidEciDesignator(..))
during build.
pub fn with_exact_version(
builder: Builder,
version: Int,
) -> Builder
Pin the symbol version exactly.
The value is interpreted relative to the active symbol family: Standard QR accepts 1..40, Micro QR accepts 1..4 (M1..M4), and rMQR accepts 1..32 (R7x43..R17x139).
If the payload, mode, or ECC level cannot be satisfied at the requested
version, build returns Error(DataExceedsCapacity) or
Error(IncompatibleOptions) instead of bumping to a larger version.
When no exact version is configured, the encoder selects the smallest
version that fits the payload.
pub fn with_min_version(
builder: Builder,
min_version: Int,
) -> Builder
Compatibility alias for with_exact_version.
Despite the historical name, this pins the symbol version exactly rather
than setting a lower bound. New code should prefer with_exact_version.
pub fn with_mode_preference(
builder: Builder,
preference: types.ModePreference,
) -> Builder
Change the mode optimisation strategy.
pub fn with_symbol(
builder: Builder,
symbol: types.Symbol,
) -> Builder
Select the symbol family.