Crates.io | x12-types |
lib.rs | x12-types |
version | 0.8.4 |
source | src |
created_at | 2022-05-26 21:05:18.815136 |
updated_at | 2024-04-21 10:53:50.723978 |
description | Bindings for the ASC X12 EDI definitions |
homepage | |
repository | https://github.com/apimeister/x12-types/ |
max_upload_size | |
id | 594450 |
size | 697,654 |
This library provides bindings for the ASC X12 standard.
Something missing? Please open an issue.
use x12_types::v004010::*;
let x = Transmission {
isa: ISA {
_01: "00".to_string(),
_02: " ".to_string(),
_03: "00".to_string(),
_04: " ".to_string(),
_05: "ZZ".to_string(),
_06: "SOURCE ".to_string(),
_07: "ZZ".to_string(),
_08: "TARGET ".to_string(),
_09: "220524".to_string(),
_10: "1120".to_string(),
_11: "U".to_string(),
_12: "00401".to_string(),
_13: "000000001".to_string(),
_14: "0".to_string(),
_15: "P".to_string(),
_16: ">".to_string(),
},
functional_group: vec![FunctionalGroup {
gs: GS {
_01: "QO".to_string(),
_02: "SOURCE".to_string(),
_03: "TARGET".to_string(),
_04: "20220524".to_string(),
_05: "1600".to_string(),
_06: "1".to_string(),
_07: "X".to_string(),
_08: "004010".to_string(),
},
...
ge: GE {
_01: "1".to_string(),
_02: "1".to_string(),
},
}],
iea: IEA {
_01: "1".to_string(),
_02: "000000001".to_string(),
},
};
let serialized = format!("{x}");
// resulting string
//
// ISA*00* *00* *ZZ*SOURCE *ZZ*TARGET *220524*1120*U*00401*000000001*0*P*>~
// GS*QO*SOURCE*TARGET*20220524*1600*1*X*004010~
// ....
// GE*1*1~
// IEA*1*000000001~
use x12_types::v005010::*;
let str = r#"ISA*01*0000000000*01*0000000000*ZZ*ABCDEFGHIJKLMNO*ZZ*123456789012345*101127*1719*U*00400*000003438*0*P*>~
GS*HP*ABCCOM*01017*20110315*1005*1*X*004010X091A1~
ST*835*07504123~
BPR*H*5.75*C*NON************20110315~
...
SE*93*07504123~
GE*1*1~
IEA*1*004075123~"#;
let (rest, obj) = Transmission::<_835>::parse(&str).unwrap();
println!("{obj:?}");
// resulting string
//
// Transmission { isa:
// ISA { _01: "01", _02: "0000000000", _03: "01", _04: "0000000000", _05: "ZZ", _06: "ABCDEFGHIJKLMNO", _07: "ZZ", _08: "123456789012345", _09: "101127", _10: "1719", _11: "U", _12: "00400", _13: "000003438", _14: "0", _15: "P", _16: ">" },
// functional_group: [
// FunctionalGroup {
// gs: GS { _01: "HP", _02: "ABCCOM", _03: "01017", _04: "20110315", _05: "1005", _06: "1", _07: "X", _08: "004010X091A1" },
// segments: [_835 { ...
More examples are located in the examples directory. Tests are embedded into each version directory.
We are also maintaining a CLI-tool for a more accessible way to consume EDIs.
https://crates.io/crates/edi-cli
Since the X12 is fairly huge, we only implement types on demand. So if you are missing some types, please open an issue or merge request.