Rust API
The Rust API is documented inline via rustdoc. See docs.rs/langmail for the authoritative, versioned reference โ including error variants, method receivers, and serde derivations.
Surface at a glance
Entry points and options. Payload structs (Address, CallToAction,
ThreadMessage) and the provider-adapter entry point (preprocess_parsed /
ParsedInput) are documented on docs.rs/langmail.
| Item | Description |
|---|---|
preprocess |
fn preprocess(raw: &[u8]) -> Result<ProcessedEmail, LangmailError> |
preprocess_with_options |
Preprocess with a custom PreprocessOptions |
adapters::preprocess_gmail |
fn preprocess_gmail(msg_json: &str) -> Result<ProcessedEmail, LangmailError> โ normalize a Gmail API Schema$Message (JSON) through the shared pipeline |
adapters::preprocess_gmail_with_options |
As above, with a PreprocessOptions override |
ProcessedEmail |
The parsed output struct |
ProcessedEmail::to_llm_context |
Method on ProcessedEmail returning the LLM-ready string |
ProcessedEmail::to_llm_context_with_options |
As above, with a LlmContextOptions |
PreprocessOptions |
strip_quotes, strip_signature, max_body_length |
LlmContextOptions |
render_mode: RenderMode |
RenderMode |
LatestOnly | ThreadHistory |
LangmailError |
Error variants returned by preprocess |
Notes
preprocessreturns aResult; unlike the Node and Python bindings, there is no exception channel.to_llm_contextis a method onProcessedEmail, not a free function.- All data types (
ProcessedEmail,Address,CallToAction,ThreadMessage,PreprocessOptions,LlmContextOptions,RenderMode) deriveserde::Serialize/Deserializefor JSON round-tripping.LangmailErrordoes not. - Provider adapters live under
langmail::adapters. They take the provider's JSON as&strโ serialize a Gmailusers.messages.getresponse withserde_json::to_stringand pass the result. The adapter walkspayload.parts, base64url-decodes the bodies, and feeds them into the same cleaning pipeline aspreprocess, so the output is byte-identical to the MIME path. Gmail-specific errors are raised asLangmailError::InvalidGmailMessageandLangmailError::BodyRequiresAttachmentFetch.