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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//! # cups-rs: Safe Rust Bindings for CUPS (Common UNIX Printing System)
//!
//! `cups-rs` provides a safe, idiomatic Rust interface to the CUPS printing system API.
//! It wraps the C CUPS library with memory-safe abstractions while maintaining high performance.
//!
//! ## Features
//!
//! - **Printer Discovery**: Enumerate and discover available printers on the network
//! - **Job Management**: Create, submit, monitor, and cancel print jobs
//! - **Authentication**: Support for password callbacks and certificate-based authentication
//! - **Multi-document Jobs**: Submit multiple documents as a single print job
//! - **Advanced Queries**: Query printer capabilities, supported media, and options
//! - **IPP Protocol**: Low-level IPP request/response handling for custom workflows
//! - **Server Configuration**: Manage CUPS server settings, encryption, and user preferences
//! - **Localization**: Get localized printer option names and values
//!
//! ## Quick Start
//!
//! ### Discovering Printers
//!
//! ```no_run
//! use cups_rs::get_all_destinations;
//!
//! let printers = get_all_destinations().expect("Failed to get printers");
//! for printer in printers {
//! println!("Printer: {} ({})", printer.name,
//! if printer.is_default { "default" } else { "available" });
//! }
//! ```
//!
//! ### Printing a Document
//!
//! ```no_run
//! use cups_rs::{get_default_destination, create_job};
//!
//! let printer = get_default_destination().expect("No default printer");
//! let job = create_job(&printer, "My Document")
//! .expect("Failed to create job");
//!
//! job.submit_file("document.pdf", "application/pdf")
//! .expect("Failed to submit document");
//! ```
//!
//! ### Advanced Job Options
//!
//! ```no_run
//! use cups_rs::{get_destination, create_job_with_options, PrintOptions, ColorMode, DuplexMode, Orientation};
//!
//! let printer = get_destination("MyPrinter").expect("Printer not found");
//!
//! let options = PrintOptions::default()
//! .copies(3)
//! .color_mode(ColorMode::Color)
//! .duplex(DuplexMode::TwoSidedPortrait)
//! .orientation(Orientation::Landscape);
//!
//! let job = create_job_with_options(&printer, "Report", &options)
//! .expect("Failed to create job");
//! ```
//!
//! ## Module Overview
//!
//! - [`auth`]: Authentication and security layer (password callbacks, certificates)
//! - [`config`]: CUPS server configuration (server, user, encryption settings)
//! - [`connection`]: Direct HTTP connections to printers and CUPS servers
//! - [`destination`]: Printer discovery and destination management
//! - [`ipp`]: Low-level IPP (Internet Printing Protocol) request/response handling
//! - [`job`]: Print job creation, submission, and management
//! - [`options`]: Print option parsing, encoding, and manipulation
//! - [`Error`] and [`Result`]: Error types and result handling
//!
//! ## API Coverage
//!
//! This library currently implements approximately 70% of the CUPS C API, focusing on:
//! - Core printing workflows
//! - Enterprise features (authentication, multi-server support)
//! - Advanced destination and job management
//! - Low-level IPP protocol access
//!
//! ## Safety
//!
//! All unsafe FFI calls to the CUPS C library are wrapped in safe Rust abstractions.
//! Memory management is handled automatically using RAII patterns with Drop implementations.
//!
//! ## Platform Support
//!
//! - Linux (tested)
//! - macOS (should work, uses system CUPS)
//! - Other UNIX-like systems with CUPS installed
//!
//! ## Requirements
//!
//! - CUPS development libraries (`libcups2-dev` on Debian/Ubuntu, `cups-devel` on Fedora)
//! - Rust 1.70 or later
/// Authentication and security layer for CUPS
///
/// This module provides functionality for:
/// - Password callback registration for GUI applications
/// - Client certificate callback setup
/// - Server certificate validation
/// - Authentication handling
/// Raw FFI bindings to the CUPS C library
///
/// This module contains auto-generated bindings created by bindgen.
/// Most users should use the safe wrappers in other modules instead.
/// CUPS server configuration management
///
/// Configure CUPS server settings including:
/// - Server hostname/address
/// - User credentials
/// - Encryption modes (never, if-requested, required, always)
/// - HTTP user agent strings
/// - Scoped configuration with automatic restoration
/// Direct HTTP connection management for printers and CUPS servers
///
/// Provides low-level connection control with:
/// - Connection timeouts
/// - Cancellation support
/// - Direct device vs scheduler connections
/// - Connection monitoring via callbacks
/// CUPS constants and enums
/// Printer discovery and destination management
///
/// Core functionality for working with printers:
/// - Enumerate available destinations
/// - Query printer capabilities and status
/// - Manage destination lists (add/remove/default)
/// - Check supported options and media sizes
/// - Resolve option conflicts
/// Low-level IPP (Internet Printing Protocol) request/response handling
///
/// Build and send custom IPP requests for advanced use cases:
/// - Create IPP requests with custom operations
/// - Add attributes (strings, integers, booleans, arrays)
/// - Send requests and receive responses
/// - Parse response attributes
/// - Type-safe enums for IPP operations, tags, and status codes
/// Print job creation, submission, and management
///
/// Comprehensive job handling:
/// - Create single and multi-document jobs
/// - Submit files and raw data
/// - Query job status and attributes
/// - Cancel and manage jobs
/// - Rich print options (copies, color, duplex, media, orientation)
/// Print option parsing, encoding, and manipulation
///
/// Utilities for working with CUPS print options:
/// - Parse command-line style option strings
/// - Add/remove options from arrays
/// - Type-safe integer options
/// - Encode options to IPP attributes
/// - Get option values with type conversion
pub use *;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;