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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//! t-rec - Terminal Recorder Library
//!
//! This library provides programmatic access to t-rec's recording capabilities.
//! It is primarily designed for recording animations and GUI windows to GIF and MP4 format.
//!
//! # Feature Flags
//!
//! - `lib` - Enables the library API with [`HeadlessRecorder`]
//!
//! # Type-Safe Configuration
//!
//! The library uses strongly-typed enums for configuration options, providing compile-time
//! safety and clear documentation of valid values:
//!
//! - [`types::Decor`] - Decoration style (None, Shadow)
//! - [`types::BackgroundColor`] - Background color (Transparent, White, Black, or custom hex)
//! - [`wallpapers::Wallpaper`] - Wallpaper source (Ventura, or custom path)
//!
//! Validation happens at enum construction time via factory methods:
//! - `BackgroundColor::custom("#ff0000")` - Validates hex format
//! - `Wallpaper::custom("/path/to/image.png")` - Validates path exists
//!
//! The builder is always infallible - only `build()` can fail (for missing required fields).
//!
//! # Example
//!
//! ```ignore
//! use t_rec::HeadlessRecorder;
//! use t_rec::types::{Decor, BackgroundColor};
//! use t_rec::wallpapers::Wallpaper;
//!
//! // Type-safe enum API (compile-time checked)
//! let mut recorder = HeadlessRecorder::builder()
//! .window_id(12345)
//! .fps(30)
//! .decor(Decor::Shadow)
//! .bg_color(BackgroundColor::White)
//! .wallpaper(Wallpaper::Ventura, 60)
//! .output_gif("demo.gif")
//! .build()?;
//!
//! // Custom values use factory methods for validation
//! let mut recorder = HeadlessRecorder::builder()
//! .window_id(12345)
//! .bg_color(BackgroundColor::custom("#ff5500")?) // Validates hex format
//! .wallpaper(Wallpaper::custom("/path/to/bg.png")?, 80) // Validates path exists
//! .output_gif("demo.gif")
//! .build()?;
//!
//! // Start recording
//! recorder.start()?;
//!
//! // ... run your animation or GUI ...
//!
//! // Stop and generate output files
//! let output = recorder.stop_and_generate()?;
//! println!("Captured {} frames", output.frame_count);
//! if let Some(gif_path) = output.gif_path {
//! println!("GIF saved to: {}", gif_path.display());
//! }
//! if let Some(mp4_path) = output.mp4_path {
//! println!("MP4 saved to: {}", mp4_path.display());
//! }
//! ```
// Core shared modules - made public so binary can use it directly
// This avoids code duplication between lib and bin targets
// Library API (only compiled when not building CLI binary)
// Re-export core types
pub use ;
// Re-export public modules
pub use error;
pub use types;
pub use ;
pub use wallpapers;
pub use load_and_validate_wallpaper;
pub use ;
// Re-export headless recorder API (only when not building CLI)
pub use ;
// Re-export CLI-only items when cli feature is enabled
// These are used by the binary but need to be exported to avoid dead code warnings
pub use ;
pub use ;
pub use DEFAULT_SHELL;
pub use DEFAULT_SHELL;
pub use post_process_screenshots;
pub use ;