Sign in

    allenli178/moon-qrcode/core does not have a README file

    QrError

    pub(all) suberror QrError {
    EmptyInput
    DataTooLong(needed~ : Int, capacity~ : Int, version~ : Int, ec_level~ : EcLevel)
    InvalidVersion(Int)
    InvalidCharacter(char~ : Char, mode~ : Mode)
    InvalidColor(String)
    Internal(String)
    }

    QrError::message

    fn QrError::message(self : QrError) -> String

    Human readable diagnostic; messages name the violated constraint.

    可读的错误诊断信息,描述被违反的约束。

    EcLevel

    pub(all) enum EcLevel {
    L
    M
    Q
    H
    } derive(Eq,
    Debug
    )

    Error correction level. Capacity order is L > M > Q > H.

    纠错等级。容量顺序为 L > M > Q > H。
    impl Show for EcLevel

    EcLevel::equal

    fn EcLevel::equal(EcLevel, EcLevel) -> Bool

    EcLevel::not_equal

    fn EcLevel::not_equal(x : EcLevel, y : EcLevel) -> Bool

    EcLevel::output

    fn EcLevel::output(self : EcLevel, logger : &Logger) -> Unit

    EcLevel::to_repr

    EcLevel::to_string

    fn EcLevel::to_string(self : EcLevel) -> String

    Mask

    pub(all) enum Mask {
    M0
    M1
    M2
    M3
    M4
    M5
    M6
    M7
    } derive(Eq,
    Debug
    )

    Data mask patterns 0..7.

    数据掩码图案 0..7。
    impl Show for Mask

    Mask::equal

    fn Mask::equal(Mask, Mask) -> Bool

    Mask::not_equal

    fn Mask::not_equal(x : Mask, y : Mask) -> Bool

    Mask::output

    fn Mask::output(self : Mask, logger : &Logger) -> Unit

    Mask::to_repr

    Mask::to_string

    fn Mask::to_string(self : Mask) -> String

    Mode

    pub(all) enum Mode {
    Numeric
    Alphanumeric
    Byte
    } derive(Eq,
    Debug
    )

    Segment mode defined by ISO/IEC 18004 Model 2.

    ISO/IEC 18004 Model 2 定义的段模式。
    impl Show for Mode

    Mode::equal

    fn Mode::equal(Mode, Mode) -> Bool

    Mode::not_equal

    fn Mode::not_equal(x : Mode, y : Mode) -> Bool

    Mode::output

    fn Mode::output(self : Mode, logger : &Logger) -> Unit

    Mode::to_repr

    Mode::to_string

    fn Mode::to_string(self : Mode) -> String

    QrCode

    pub struct QrCode {
    version_ : Version
    ec_level_ : EcLevel
    mask_ : Mask
    size_ : Int
    modules_ : Array[Bool]
    }

    A finished, masked QR code symbol.

    已完成的、已应用掩码的 QR 码符号。

    QrCode::ec_level

    fn QrCode::ec_level(self : QrCode) -> EcLevel

    QrCode::get

    fn QrCode::get(self : QrCode, row : Int, col : Int) -> Bool

    Returns whether the module at row, col is dark. Panics when out of range.

    返回指定位置 (row, col) 的模块是否为深色。越界时会 panic。

    QrCode::mask

    fn QrCode::mask(self : QrCode) -> Mask

    QrCode::modules

    fn QrCode::modules(self : QrCode) -> Array[Bool]

    Row-major copy of the module matrix.

    行优先的模块矩阵副本。

    QrCode::size

    fn QrCode::size(self : QrCode) -> Int

    QrCode::to_bytes

    fn QrCode::to_bytes(self : QrCode) -> Array[Byte]

    Row-major bytes, 1 for dark and 0 for light.

    行优先字节数组,1 表示深色,0 表示浅色。

    QrCode::version

    fn QrCode::version(self : QrCode) -> Version

    Segment

    pub struct Segment {
    mode_ : Mode
    data_ : String
    }

    A run of input characters encoded with one mode.

    使用同一模式编码的一段输入字符。

    Segment::char_count

    fn Segment::char_count(self : Segment) -> Int

    Character count written into the segment header.

    写入段头的字符计数。

    Segment::data

    fn Segment::data(self : Segment) -> String

    Segment::data_bits

    fn Segment::data_bits(self : Segment) -> Int

    Payload bit length, excluding mode and character-count fields.

    载荷比特长度,不含模式和字符计数字段。

    Segment::mode

    fn Segment::mode(self : Segment) -> Mode

    Segment::new

    fn Segment::new(mode : Mode, data : String) -> Segment

    Version

    pub struct Version(Int) derive(Eq)

    QR version 1..40. Values can only be built through Version::new.

    QR 版本 1..40。只能通过 Version::new 构造。

    Version::char_count_bits

    fn Version::char_count_bits(self : Version, mode : Mode) -> Int

    Version::character_capacity

    fn Version::character_capacity(self : Version, ec : EcLevel, mode : Mode) -> Int

    Version::data_capacity_bits

    fn Version::data_capacity_bits(self : Version, ec : EcLevel) -> Int

    Version::data_codewords

    fn Version::data_codewords(self : Version, ec : EcLevel) -> Int

    Version::equal

    fn Version::equal(Version, Version) -> Bool

    Version::new

    fn Version::new(value : Int) -> Version?

    Version::not_equal

    fn Version::not_equal(x : Version, y : Version) -> Bool

    Version::size

    fn Version::size(self : Version) -> Int

    Side length in modules (4 * version + 17).

    模块边长(4 * version + 17)。

    Version::total_codewords

    fn Version::total_codewords(self : Version) -> Int

    Version::value

    fn Version::value(self : Version) -> Int

    bits_needed

    fn bits_needed(segments : Array[Segment], version : Int) -> Int

    Total bits needed for the segments at a given version, headers included.

    给定版本下所有段的总比特数,包含段头。

    block_count

    fn block_count(version : Int, ec : EcLevel) -> Int

    char_count_bits

    fn char_count_bits(version : Int, mode : Mode) -> Int

    character_capacity

    fn character_capacity(version : Int, ec : EcLevel, mode : Mode) -> Int

    Maximum number of characters of the given mode that fit in a version/EC pair.

    给定版本/纠错等级下,指定模式可容纳的最大字符数。

    data_capacity_bits

    fn data_capacity_bits(version : Int, ec : EcLevel) -> Int

    data_codewords

    fn data_codewords(version : Int, ec : EcLevel) -> Int

    ecc_codewords

    fn ecc_codewords(version : Int, ec : EcLevel) -> Int

    encode

    fn encode(text : String, ec_level? : EcLevel, min_version? : Int, max_version? : Int, mode? : Mode, mask? : Mask) -> QrCode raise QrError

    Encodes text as a QR Model 2 symbol.

    将 text 编码为 QR Model 2 符号。

    ec_level defaults to M, version range to 1..40, mode is chosen automatically, and the mask is selected by minimizing the Annex J penalty.

    ec_level 默认为 M,版本范围为 1..40,模式自动选择, 掩码通过最小化 Annex J 惩罚分选出。

    Example

    test "encode hello world" {
    let qr = @core.encode("HELLO WORLD") // V1-M
    assert_eq(qr.size(), 21)
    assert_eq(qr.version().value(), 1)
    }

    format_info

    fn format_info(ec : EcLevel, mask : Mask) -> Int

    BCH(15,5) format information, masked with 0x5412 as required by ISO 7.9.

    BCH(15,5) 格式信息,按 ISO 7.9 要求与 0x5412 异或掩码。

    gf_mul

    fn gf_mul(a : Byte, b : Byte) -> Byte

    Multiplication in GF(2^8).

    GF(2^8) 上的乘法。

    rs_encode

    fn rs_encode(msg : ArrayView[Byte], nsym : Int) -> Array[Byte]

    Reed-Solomon parity bytes for msg with nsym ECC codewords.

    对 msg 计算 nsym 个 ECC 校验字节的 Reed-Solomon 编码。

    split_segments

    fn split_segments(text : String, mode? : Mode) -> Array[Segment] raise QrError

    Splits text into greedy class runs. Forcing mode produces a single segment and rejects characters outside that mode's repertoire.

    将文本拆分为贪心分类段。强制指定 mode 时生成单个段, 并拒绝该模式字符集之外的字符。

    total_codewords

    fn total_codewords(version : Int) -> Int

    Number of data + ECC modules available for codewords, divided by 8. Derived from ISO Table 1; remainder bits are not counted.

    可用于码字的数据 + ECC 模块数除以 8。 源自 ISO Table 1;不计余留位。

    version_info

    fn version_info(version : Int) -> Int?

    BCH(18,6) version information for versions 7..40; None below 7.

    BCH(18,6) 版本信息,适用于版本 7..40;低于 7 时返回 None。