convert to library

This commit is contained in:
Quentin 2023-06-08 21:55:07 +02:00
parent 93576dfeff
commit 10c5968676
Signed by: quentin
GPG key ID: E9602264D639FF68
4 changed files with 14 additions and 4 deletions

View file

@ -5,5 +5,14 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "imf_codec"
path = "src/lib.rs"
[[bin]]
name = "imf_parse"
path = "src/parse.rs"
[dependencies]
nom = "7"

View file

@ -124,7 +124,7 @@ fn unstructured(input: &str) -> IResult<&str, String> {
let body = match r.as_slice() {
[(None, content)] => content.to_string(),
[(Some(ws), content)] => ws.to_string() + content,
lines => lines.iter().fold(String::with_capacity(255), |mut acc, item| {
lines => lines.iter().fold(String::with_capacity(255), |acc, item| {
let (may_ws, content) = item;
match may_ws {
Some(ws) => acc + ws + content,

3
src/lib.rs Normal file
View file

@ -0,0 +1,3 @@
pub mod headers;
pub mod model;
mod abnf;

View file

@ -1,6 +1,4 @@
mod headers;
mod model;
mod abnf;
use imf_codec::headers;
fn main() {
let header = "Subject: Hello\r\n World\r\nFrom: <quentin@deuxfleurs.fr>\r\n\r\n";