convert to library
This commit is contained in:
parent
93576dfeff
commit
10c5968676
4 changed files with 14 additions and 4 deletions
|
@ -5,5 +5,14 @@ edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# 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]
|
[dependencies]
|
||||||
nom = "7"
|
nom = "7"
|
||||||
|
|
|
@ -124,7 +124,7 @@ fn unstructured(input: &str) -> IResult<&str, String> {
|
||||||
let body = match r.as_slice() {
|
let body = match r.as_slice() {
|
||||||
[(None, content)] => content.to_string(),
|
[(None, content)] => content.to_string(),
|
||||||
[(Some(ws), content)] => ws.to_string() + content,
|
[(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;
|
let (may_ws, content) = item;
|
||||||
match may_ws {
|
match may_ws {
|
||||||
Some(ws) => acc + ws + content,
|
Some(ws) => acc + ws + content,
|
||||||
|
|
3
src/lib.rs
Normal file
3
src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub mod headers;
|
||||||
|
pub mod model;
|
||||||
|
mod abnf;
|
|
@ -1,6 +1,4 @@
|
||||||
mod headers;
|
use imf_codec::headers;
|
||||||
mod model;
|
|
||||||
mod abnf;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let header = "Subject: Hello\r\n World\r\nFrom: <quentin@deuxfleurs.fr>\r\n\r\n";
|
let header = "Subject: Hello\r\n World\r\nFrom: <quentin@deuxfleurs.fr>\r\n\r\n";
|
Loading…
Reference in a new issue