serde_x12 0.7.0

A Serde for ASC X12 EDI documents.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::Error;

pub fn from_str<'a, T>(s: &'a str) -> Result<T, Error>
where
    T: Default + nom::Parser<&'a str, T, nom::error::Error<&'a str>>,
{
    let mut x = T::default();
    let result = x.parse(s);
    match result {
        Ok(val) => Ok(val.1),
        Err(err) => Err(Error::Message(format!("failed: {:?}", err))),
    }
}