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
196
197
198
199
//! # dynpatch
//!
//! Safe live code reloading for Rust applications.
//!
//! `dynpatch` enables runtime hot-patching of Rust code with strong safety guarantees,
//! transactional semantics, and automatic rollback on failure.
//! ## Features
//!
//! - **Runtime hot patching**: Update code without restarting
//! - **Safety first**: Strong ABI/type compatibility checks
//! - **Transactional**: All-or-nothing activation with automatic rollback
//! - **State continuity**: Optional state migration between versions
//! - **Minimal overhead**: Lock-free implementation swapping
//! - **Developer friendly**: Macros, CLI, file watching, and introspection
//!
//! ## Quick Start
//!
//! ### Basic Usage
//!
//! ```rust,ignore
//! use dynpatch::prelude::*;
//!
//! // Initialize the runtime
//! init();
//!
//! // Load a patch
//! reload("path/to/patch.so")?;
//!
//! // Check active patch
//! if let Some(info) = active_patch_info() {
//! println!("Active: {} v{}", info.name, info.version);
//! }
//!
//! // Rollback if needed
//! rollback()?;
//! ```
//!
//! ### Advanced Configuration
//!
//! ```rust,ignore
//! use dynpatch::prelude::*;
//! use dynpatch_interface::Version;
//!
//! // Configure the runtime with specific requirements
//! RuntimeBuilder::new()
//! .interface_version(Version::new(1, 0, 0))
//! .type_hash(0x1234567890abcdef)
//! .init();
//! ```
//!
//! ### Mark code as patchable
//!
//! ```rust,ignore
//! use dynpatch::prelude::*;
//!
//! #[patch_trait]
//! pub trait Handler {
//! fn handle(&self, request: Request) -> Response;
//! }
//!
//! #[patchable]
//! fn process_data(data: &str) -> String {
//! data.to_uppercase()
//! }
//! ```
//!
//! ### Hot-reload configuration
//!
//! ```rust,ignore
//! use dynpatch::config::*;
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Debug, Clone, Deserialize, Serialize)]
//! struct AppConfig {
//! max_connections: usize,
//! timeout_ms: u64,
//! }
//!
//! impl HotConfig for AppConfig {}
//!
//! fn main() {
//! let watcher = watch::<AppConfig, _>("config.toml").unwrap();
//!
//! loop {
//! let config = watcher.get();
//! println!("Max connections: {}", config.max_connections);
//! std::thread::sleep(std::time::Duration::from_secs(1));
//! }
//! }
//! ```
//!
//! ## Architecture
//!
//! dynpatch consists of several components:
//!
//! - **dynpatch-core**: Runtime engine for loading and managing patches
//! - **dynpatch-macro**: Procedural macros for marking patchable code
//! - **dynpatch-interface**: Shared types for host-patch communication
//! - **dynpatch-watcher**: File watching and config reloading
//! - **dynpatch-cli**: Command-line tool for building and managing patches
//!
//! ## Safety Guarantees
//!
//! - **ABI validation**: Type layout and signature checking before activation
//! - **Version compatibility**: Semantic versioning with compatibility rules
//! - **Transactional swaps**: Atomic activation with automatic rollback on failure
//! - **Thread safety**: Lock-free RCU-like publication using `arc-swap`
//! - **Panic safety**: Catch initialization panics and rollback
//!
//! ## Optional Features
//!
//! - `watcher` (default) - File watching and config reloading
//! - `abi_stable` - Enhanced ABI checks using `abi_stable` crate
//! - `metrics` - Performance and operation metrics
//! - `signing` - Cryptographic patch signature verification
//! - `sandbox` - Process isolation for untrusted patches
//! - `json`, `yaml`, `toml` - Config format support
// Re-export core functionality
pub use ;
// Re-export interface types
pub use ;
// Re-export macros
pub use ;
// Re-export watcher functionality (if enabled)
pub use watch;
/// Prelude module for convenient imports
///
/// This module re-exports the most commonly used items for easy access.
///
/// # Example
///
/// ```rust,ignore
/// use dynpatch::prelude::*;
///
/// init();
/// reload("patch.so")?;
/// ```