GS1-128 and Code 128 data parser toolkit for MoonBit logistics applications.
///|
test "README quick start" {
let message = parse_gs1("(01)09501101530003(10)LOT42(17)260930")
assert_eq(message.first_value("01"), Some("09501101530003"))
assert_eq(message.first_value("10"), Some("LOT42"))
assert_true(message.validate().ok)
assert_eq(message.profile().has_expiration, true)
}moon run cmd/main -- --validate --encode --benchmark
moon run cmd/main -- "(01)09501101530003(10)LOT42" --validate --encode
moon run cmd/main -- "(01)09501101530003(10)LOT42" --ascii///|
test "README Code 128 example" {
let encoded = encode_code128("123456").unwrap()
assert_eq(encoded.symbols, [105, 12, 34, 56, 44, 106])
assert_eq(encoded.checksum, 44)
assert_true(verify_code128_symbols(encoded.symbols))
}.
|-- types.mbt public GS1 types and base catalog
|-- catalog.mbt commercial, logistics and internal AI metadata
|-- measurement.mbt 310–369 measurement families and conversion helpers
|-- parser.mbt HRI/raw state-machine parser
|-- parser_options.mbt strict/auto/raw parser policies
|-- scanner.mbt line and scanner-stream normalization
|-- batch.mbt per-record batch results
|-- validation.mbt report construction and date rules
|-- check_digits.mbt GS1 identifier algorithms
|-- validation_profiles.mbt traceability/shipment profiles
|-- normalized.mbt dates, implied decimals and safe views
|-- pipeline.mbt warehouse projection helpers
|-- code128.mbt encoder, checksum and GS1-128 bridge
|-- code128_tables.mbt complete Code 128 module patterns
|-- benchmark.mbt reproducible operation-count reports
|-- cmd/main runnable CLI example
`-- .github/workflows check/test and manual publish workflowsmoon run cmd/main -- --benchmark///|
test "README benchmark example" {
let report = benchmark_parse(
"(01)09501101530003(10)BATCH-7(17)260930",
iterations=10,
)
assert_eq(report.successes, 10)
assert_eq(report.fields, 30)
assert_true(report.operations > 0)
}moon fmt --check
moon check --target all --deny-warn
moon test --target all --deny-warn
moon coverage report -f summary
moon coverage analyzepub suberror ParseError {
UnknownAI(String)
Truncated(String, Int, Int)
InvalidSyntax(String)
} derive(Debug)pub struct BatchReport {
total : Int
succeeded : Int
failed : Int
records : Array[BatchRecord]
} derive(Eq, Debug)fn application_rule_allows_separator(code : String) -> Bool?fn application_rule_needs_check_digit(code : String) -> Bool?fn application_rule_validate_length(code : String, value : String) -> Boolfn measurement_compare(code : String, left : String, right : String) -> Intfn measurement_from_scaled_integer(code : String, value : Int) -> String?fn measurement_normalize_encoded(code : String, encoded : String) -> String?fn measurement_to_scaled_integer(code : String, encoded : String) -> Int?fn measurement_value_as_decimal(code : String, encoded : String) -> String?fn render_code128_ascii(encoded : Code128Encoded, quiet_zone? : Int, bar? : String, space? : String) -> StringGS1-128 and Code 128 data parser toolkit for MoonBit logistics applications.