Skip to main content

preprocess

Function preprocess 

Source
pub fn preprocess(raw: &[u8]) -> Result<ProcessedEmail, LangmailError>
Expand description

Preprocess a raw email (RFC 5322 / EML format) into an LLM-ready structure.

This is the primary entry point for langmail. It takes raw email bytes and returns a structured ProcessedEmail with clean body text, metadata, and thread information — optimized for feeding into language models.

§Example

let raw = b"From: alice@example.com\r\nTo: bob@example.com\r\nSubject: Hello\r\n\r\nHi Bob!";
let output = langmail::preprocess(raw).unwrap();
assert!(output.body.contains("Hi Bob!"));