[][src]Crate 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.


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:

Getting Started

There are examples in the examples directory.



Represents an entire parsed EDI document with both the envelope (i.e. metadata) and the data segments.


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.


Represents a GS/GE segment which wraps a functional group. Documentation here gleaned mostly from here


A generic segment.


Represents the ISA/IEA header information commonly known as the "envelope" in X12 EDI.


Represents a transaction in an EDI document. A transaction is initialized with an ST segment and ended with an SE segment.



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.


This is the main entry point to the crate. Parse an input str and output either an EdiParseError or a resulting EdiDocument.