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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
//! XMPKit - Pure Rust implementation of Adobe XMP Toolkit
//!
//! XMPKit is a pure Rust implementation of Adobe's XMP (Extensible Metadata Platform) Toolkit.
//! It provides APIs for reading, writing, and manipulating XMP metadata in various file formats
//! without c++ SDK bridge.
//!
//! ## Features
//!
//! - Pure Rust implementation
//! - Compatible with Adobe XMP standard
//! - Support for common file formats (e.g., JPEG, PNG, TIFF, MP3, GIF, MP4)
//! - Memory safe and high performance
//! - Cross-platform support (iOS, Android, HarmonyOS, macOS, Windows, Linux, Wasm)
//!
//! ## Quick Start
//!
//! ### Working with Files (Native Platforms)
//!
//! ```rust,no_run
//! use xmpkit::{XmpFile, XmpMeta, XmpValue};
//! use xmpkit::core::namespace::ns;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Open a file
//! let mut file = XmpFile::new();
//! file.open("image.jpg")?;
//!
//! // Read XMP metadata
//! if let Some(meta) = file.get_xmp() {
//! if let Some(creator) = meta.get_property(ns::XMP, "CreatorTool") {
//! println!("Creator: {:?}", creator);
//! }
//! }
//!
//! // Modify metadata
//! if let Some(mut meta) = file.get_xmp().cloned() {
//! meta.set_property(
//! ns::XMP,
//! "CreatorTool",
//! XmpValue::String("MyApp".to_string()),
//! )?;
//! file.put_xmp(meta);
//! }
//!
//! // Save changes
//! file.save("output.jpg")?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Working with Bytes (Wasm and Memory-based Operations)
//!
//! ```rust,no_run
//! use xmpkit::{XmpFile, XmpMeta, XmpValue};
//! use xmpkit::core::namespace::ns;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let jpeg_data: &[u8] = &[]; // your JPEG file data
//!
//! // Load from bytes
//! let mut file = XmpFile::new();
//! file.from_bytes(jpeg_data)?;
//!
//! // Read and modify metadata
//! if let Some(mut meta) = file.get_xmp().cloned() {
//! meta.set_property(
//! ns::XMP,
//! "CreatorTool",
//! XmpValue::String("MyApp".to_string()),
//! )?;
//! file.put_xmp(meta);
//! }
//!
//! // Write back to bytes
//! let output_data = file.write_to_bytes()?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Parsing XMP from String
//!
//! ```rust
//! use xmpkit::{XmpMeta, XmpValue};
//! use xmpkit::core::namespace::ns;
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let xmp_packet = r#"<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
//! <x:xmpmeta xmlns:x="adobe:ns:meta/">
//! <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
//! <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
//! <xmp:CreatorTool>MyApp</xmp:CreatorTool>
//! </rdf:Description>
//! </rdf:RDF>
//! </x:xmpmeta><?xpacket end="w"?>"#;
//!
//! let meta = XmpMeta::parse(xmp_packet)?;
//!
//! if let Some(creator) = meta.get_property(ns::XMP, "CreatorTool") {
//! println!("Creator: {:?}", creator);
//! }
//!
//! // Modify and serialize
//! let mut meta = meta;
//! meta.set_property(
//! ns::XMP,
//! "ModifyDate",
//! XmpValue::DateTime("2024-01-01T00:00:00Z".to_string()),
//! )?;
//!
//! let serialized = meta.serialize_packet()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Modules
//!
//! - [`core`] - Core XMP functionality (parsing, serialization, metadata API)
//! - [`files`] - File format handlers for reading/writing XMP from files
//! - [`types`] - Common types and data structures (XmpValue, Qualifier)
//! - [`utils`] - Utility functions (date/time handling)
//!
//! ## Platform Support
//!
//! ### Native Platforms (iOS, Android, HarmonyOS, macOS, Windows, Linux)
//!
//! Native platforms support both file I/O and memory-based operations:
//!
//! - `XmpFile::open()` - Open files from file system
//! - `XmpFile::save()` - Save files to file system
//! - `XmpFile::from_bytes()` - Load from memory (also available)
//! - `XmpFile::write_to_bytes()` - Write to memory (also available)
//!
//! ### WebAssembly (Wasm)
//!
//! Wasm platforms support memory-based operations only:
//!
//! - `XmpFile::from_bytes()` - Load from memory
//! - `XmpFile::from_reader()` - Load from reader
//! - `XmpFile::write_to_bytes()` - Write to memory
//! - `XmpFile::write_to_writer()` - Write to writer
//!
//! To use xmpkit in JavaScript, enable the `wasm` feature:
//!
//! **Simple way (recommended):**
//!
//! 1. Create a new crate: `cargo new --lib my-wasm-app`
//! 2. Add to `Cargo.toml`:
//! ```toml
//! [lib]
//! crate-type = ["cdylib"]
//! [dependencies]
//! xmpkit = { version = "0.1.0", features = ["wasm"] }
//! ```
//! 3. Re-export bindings in `src/lib.rs`:
//! ```rust,ignore
//! pub use xmpkit::wasm::*;
//! ```
//! 4. Build: `wasm-pack build --target web`
//!
//! Then use in JavaScript:
//!
//! ```javascript
//! import init, { read_xmp, write_xmp } from './pkg/my_wasm_app.js';
//! await init();
//! const result = read_xmp(new Uint8Array(/* file bytes */));
//! ```
//!
//! **Alternative**: Create a custom binding crate (see `docs/WEBASSEMBLY.md` for details)
//!
//! ### OpenHarmony/HarmonyOS (ArkTS)
//!
//! To use xmpkit in OpenHarmony/HarmonyOS applications, enable the `ohos` feature:
//!
//! 1. Add to `Cargo.toml`:
//! ```toml
//! [lib]
//! crate-type = ["cdylib"]
//! [dependencies]
//! xmpkit = { version = "0.1.0", features = ["ohos"] }
//! ```
//! 2. Re-export bindings in `src/lib.rs`:
//! ```rust,ignore
//! pub use xmpkit::ohos::*;
//! ```
//! 3. Build: `ohrs build`
//!
//! Then use in ArkTS:
//!
//! ```typescript
//! import { XmpFile, XmpMeta } from 'libxmpkit.so';
//! const file = new XmpFile();
//! file.fromBytes(fileBytes);
//! const meta = file.getXmp();
//! ```
//!
//! ## Feature Flags
//!
//! - `core` - Core XMP functionality (enabled by default)
//! - `files` - File format support infrastructure (enabled by default)
//! - `jpeg`, `png`, `tiff`, `mp3`, `gif`, `mpeg4` - Individual file format handlers
//! - `full-formats` - Enable all file format handlers (enabled by default)
//! - `mutli-thread` - Multi-threaded runtime support (enabled by default)
//! - `wasm` - WebAssembly JavaScript bindings (optional, enables wasm-bindgen integration)
//! - `ohos` - OpenHarmony/HarmonyOS Node-API bindings (optional, enables napi-ohos integration)
//!
//! ## Supported File Formats
//!
//! | Format | Extensions | Read | Write |
//! |--------|-----------|------|-------|
//! | JPEG | .jpg, .jpeg | Yes | Yes |
//! | PNG | .png | Yes | Yes |
//! | TIFF | .tif, .tiff | Yes | Yes |
//! | MP3 | .mp3 | Yes | Yes |
//! | GIF | .gif | Yes | Yes |
//! | MPEG4 | .mp4, .m4a, .m4v, .mov | Yes | Yes |
// Re-export commonly used types
pub use ;
pub use XmpMeta;
pub use ;
pub use ;
pub use Qualifier;
pub use XmpValue;
pub use XmpDateTime;