#![deny(unsafe_code)]
#![doc = include_str!("../README.md")]
use std::str::FromStr;
use serde::Deserialize;
pub mod body;
pub mod error;
pub mod header;
use error::Error;
pub type Result<T> = std::result::Result<T, crate::error::Error>;
#[derive(Debug, Deserialize, PartialEq)]
pub struct Ofx {
pub header: header::Header,
#[serde(rename = "OFX")]
pub body: body::Body,
}
impl FromStr for Ofx {
type Err = Error;
fn from_str(s: &str) -> Result<Self> {
let start = s
.find("<OFX>")
.ok_or(Error::ParseError("no `<OFX>` found".into()))?;
let (raw_header, raw_body) = (&s[..start], &s[start..]);
let header = raw_header.parse()?;
let body = raw_body.parse()?;
Ok(Self { header, body })
}
}