Crate whatsapp_export_parser

Source
Expand description

A utility crate for parsing the text file you get when exporting a WhatsApp conversation.

§Examples

The main purpose of this crate is the parse() function for parsing source text into Messages and ParseErrors.

use whatsapp_export_parser::{parse, Body, DirectMessage, Message, Span};

let src = r#"
31/10/19, 16:16 - Michael-F-Bryan: This is a message!
31/10/19, 14:13 - +60 12-345 6789: IMG-20191031-WA0005.jpg (file attached)
"#;

let parsed = dbg!(parse(src));

assert!(parsed.errors.is_empty(), "Everything should have parsed successfully");
assert_eq!(parsed.messages.len(), 2);

assert_eq!(parsed.messages[0].meta.sender, "Michael-F-Bryan");
let expected_body = Body::from(DirectMessage {
    content: String::from("This is a message!"),
    span: Span::new(36, 54),
});
assert_eq!(parsed.messages[0].body, expected_body);
assert_eq!(parsed.messages[1].meta.sender, "+60 12-345 6789");

§Cargo Features

To help reduce compile times some features have been hidden behind cargo feature flags.

  • serde-1 - implements serialization for exported types

Structs§

Enums§

Functions§

  • Try to parse some WhatsApp messages from an export file.