Expand description
§EDI
This crate is for parsing and acting on EDI X12 documents. It exposes two main entry points for parsing:
loose_parse()
and parse()
. The strictest parsing mode is parse()
, which parses a string and constructs
an EdiDocument in a zero-copy (almost – more on that later) way. loose_parse()
does the same thing, but
does not check and validate that segment closers (IEA, GE, SE) match their openers’ ID or have the correct amount
of records.
§Zero Copy
Under the hood, this crate uses std::borrow::Cow<&str>
for processing EDI documents. This means that if you are
not writing or mutating the document, it is zero copy. As soon as you write to or mutate any part of the EdiDocument
,
that one part is copied. See the documentation for std::borrow::Cow
for more details.
§Serialization
This crate also supports zero-copy serialization and deserialization via serde
. That means that this crate,
with the help of serde
, also supports serialization to:
- YAML
- JSON
- Bincode
- Pickle
- TOML
- and more…
§Getting Started
There are examples in the examples directory.
Structs§
- EdiDocument
- Represents an entire parsed EDI document with both the envelope (i.e. metadata) and the data segments.
- EdiParse
Error - Represents an error that occurred at any point in parsing a document. Contains a reason the error occurred and the segment in which the error occurred.
- Functional
Group - Represents a GS/GE segment which wraps a functional group. Documentation here gleaned mostly from here
- Generic
Segment - A generic segment.
- Interchange
Control - Represents the ISA/IEA header information commonly known as the “envelope” in X12 EDI.
- Transaction
- Represents a transaction in an EDI document. A transaction is initialized with an ST segment and ended with an SE segment.
Functions§
- loose_
parse - This is an alternate parser which does not perform closing tag validation. If you are receiving EDI documents which have had less rigor applied to their construction, this may help. The number of documents in the confirmation and the IDs on the closing tags don’t need to match.
- parse
- This is the main entry point to the crate. Parse an input str and output either an EdiParseError or a resulting EdiDocument.