1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Export messages to CSV, JSON, and JSONL formats.
//!
//! This module provides format writers optimized for different use cases.
//! Each format has both file-writing and string-generating variants.
//!
//! # Format Comparison
//!
//! | Format | Function | Feature | Best For |
//! |--------|----------|---------|----------|
//! | CSV | [`write_csv`] / [`to_csv`] | `csv-output` | LLM context (13x compression) |
//! | JSON | [`write_json`] / [`to_json`] | `json-output` | APIs, structured data |
//! | JSONL | [`write_jsonl`] / [`to_jsonl`] | `json-output` | RAG pipelines, streaming |
//!
//! # Examples
//!
//! ## Write to Files
//!
//! ```no_run
//! # #[cfg(all(feature = "csv-output", feature = "json-output"))]
//! # fn main() -> chatpack::Result<()> {
//! use chatpack::prelude::*;
//!
//! let messages = vec![
//! Message::new("Alice", "Hello!"),
//! Message::new("Bob", "Hi there!"),
//! ];
//! let config = OutputConfig::new().with_timestamps();
//!
//! write_csv(&messages, "output.csv", &config)?;
//! write_json(&messages, "output.json", &config)?;
//! write_jsonl(&messages, "output.jsonl", &config)?;
//! # Ok(())
//! # }
//! # #[cfg(not(all(feature = "csv-output", feature = "json-output")))]
//! # fn main() {}
//! ```
//!
//! ## Generate Strings (WASM-friendly)
//!
//! ```
//! # #[cfg(feature = "csv-output")]
//! # fn main() -> chatpack::Result<()> {
//! use chatpack::prelude::*;
//!
//! let messages = vec![Message::new("Alice", "Hello!")];
//! let csv = to_csv(&messages, &OutputConfig::new())?;
//!
//! assert!(csv.contains("Alice"));
//! # Ok(())
//! # }
//! # #[cfg(not(feature = "csv-output"))]
//! # fn main() {}
//! ```
//!
//! # Feature Flags
//!
//! - `csv-output`: Enables CSV functions ([`write_csv`], [`to_csv`])
//! - `json-output`: Enables JSON functions ([`write_json`], [`to_json`], [`write_jsonl`], [`to_jsonl`])
pub use ;
pub use ;
pub use ;