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
//! # Sitemap Generator
//!
//! A high-performance Rust library for generating XML sitemaps compliant with
//! the [sitemaps.org protocol 0.9](https://www.sitemaps.org/protocol.html).
//!
//! ## Features
//!
//! - **Standard XML Sitemaps**: Basic sitemaps with URLs, lastmod, changefreq, and priority
//! - **Image Sitemaps**: Include image metadata (captions, geo-location, titles, licenses)
//! - **Video Sitemaps**: Include video metadata (thumbnails, descriptions, durations, ratings)
//! - **News Sitemaps**: Submit news articles to Google News with publication metadata
//! - **Combined Sitemaps**: Combine multiple extensions (image + video + news) in one sitemap
//! - **Sitemap Index**: Manage multiple sitemap files for large websites (>50k URLs)
//! - **Validation**: Automatic validation of URLs, dates, size limits, and protocol compliance
//! - **Compression**: Built-in gzip compression (96-98% bandwidth savings)
//! - **Web Framework Support**: Direct bytes output for Axum, Actix-web, Rocket, etc.
//! - **Parsing**: Read and parse existing sitemap files
//! - **Memory Efficient**: ~140 bytes/URL during generation, 0 bytes after (proven)
//! - **High Performance**: ~830K URLs/second, immediate memory cleanup
//! - **Optimized Builders**: Pre-allocate capacity with `with_capacity()` for better performance
//!
//! ## Quick Start Examples
//!
//! ### 1. Standard Sitemap
//!
//! ```rust
//! use sitemap_generator::{SitemapBuilder, UrlEntry, ChangeFreq};
//!
//! // Use with_capacity() if you know the number of URLs in advance
//! let mut builder = SitemapBuilder::with_capacity(1000);
//!
//! builder.add_url(UrlEntry::new("https://example.com/")
//! .lastmod("2025-11-01")
//! .changefreq(ChangeFreq::Daily)
//! .priority(1.0));
//!
//! // Generate as string, bytes, or compressed
//! let xml = builder.build().unwrap();
//! let bytes = builder.build_bytes().unwrap();
//! let compressed = builder.build_compressed_bytes().unwrap();
//!
//! // Write to file
//! builder.write("sitemap.xml").unwrap();
//! builder.write_compressed("sitemap.xml.gz").unwrap();
//! ```
//!
//! ### 2. Image Sitemap
//!
//! ```rust
//! use sitemap_generator::{ImageSitemapBuilder, UrlEntry, UrlWithImages, ImageEntry};
//!
//! let mut builder = ImageSitemapBuilder::new();
//!
//! let url_with_images = UrlWithImages::new(
//! UrlEntry::new("https://example.com/gallery")
//! )
//! .add_image(
//! ImageEntry::new("https://example.com/photo1.jpg")
//! .title("Beautiful Sunset")
//! .caption("A stunning sunset over the ocean")
//! );
//!
//! builder.add_url(url_with_images);
//! let xml = builder.build().unwrap();
//! ```
//!
//! ### 3. Video Sitemap
//!
//! ```rust
//! use sitemap_generator::{VideoSitemapBuilder, UrlEntry, UrlWithVideos, VideoEntry};
//!
//! let mut builder = VideoSitemapBuilder::new();
//!
//! let url_with_video = UrlWithVideos::new(
//! UrlEntry::new("https://example.com/videos/intro")
//! )
//! .add_video(
//! VideoEntry::new(
//! "https://example.com/thumbnails/intro.jpg",
//! "Introduction Video",
//! "Learn about our product"
//! )
//! .content_loc("https://example.com/videos/intro.mp4")
//! .duration(300)
//! .rating(4.5)
//! );
//!
//! builder.add_url(url_with_video);
//! let xml = builder.build().unwrap();
//! ```
//!
//! ### 4. News Sitemap
//!
//! ```rust
//! use sitemap_generator::{NewsSitemapBuilder, UrlEntry, UrlWithNews, NewsEntry, NewsPublication};
//!
//! let mut builder = NewsSitemapBuilder::new();
//!
//! let publication = NewsPublication::new("TechDaily", "en");
//! let news = NewsEntry::new(
//! publication,
//! "2025-11-01T10:00:00Z",
//! "Breaking Tech News"
//! )
//! .keywords("technology, innovation")
//! .stock_tickers("GOOGL, MSFT");
//!
//! builder.add_url(UrlWithNews::new(
//! UrlEntry::new("https://example.com/news/article"),
//! news
//! ));
//!
//! let xml = builder.build().unwrap();
//! ```
//!
//! ### 5. Combined Sitemap (Multiple Extensions)
//!
//! ```rust
//! use sitemap_generator::{
//! CombinedSitemapBuilder, UrlEntry, UrlWithExtensions,
//! ImageEntry, VideoEntry, NewsEntry, NewsPublication
//! };
//!
//! let mut builder = CombinedSitemapBuilder::new();
//!
//! // News article with images and video
//! let news = NewsEntry::new(
//! NewsPublication::new("TechDaily", "en"),
//! "2025-11-01T10:00:00Z",
//! "AI Breakthrough"
//! );
//!
//! let image = ImageEntry::new("https://example.com/ai-lab.jpg")
//! .title("AI Research Lab");
//!
//! let video = VideoEntry::new(
//! "https://example.com/thumb.jpg",
//! "AI Demo",
//! "Watch the demo"
//! )
//! .duration(180);
//!
//! builder.add_url(
//! UrlWithExtensions::new(UrlEntry::new("https://example.com/article"))
//! .add_image(image)
//! .add_video(video)
//! .set_news(news)
//! );
//!
//! let xml = builder.build().unwrap();
//! ```
//!
//! ### 6. Sitemap Index
//!
//! ```rust
//! use sitemap_generator::{SitemapIndexBuilder, SitemapIndexEntry};
//!
//! let mut builder = SitemapIndexBuilder::new();
//!
//! builder.add_sitemap(
//! SitemapIndexEntry::new("https://example.com/sitemap1.xml.gz")
//! .lastmod("2025-11-01")
//! );
//!
//! builder.add_sitemap(
//! SitemapIndexEntry::new("https://example.com/sitemap2.xml.gz")
//! .lastmod("2025-11-02")
//! );
//!
//! let xml = builder.build().unwrap();
//! ```
//!
//! ## Web Framework Integration
//!
//! Perfect for serving sitemaps from web applications:
//!
//! ```rust,no_run
//! use sitemap_generator::{SitemapBuilder, UrlEntry};
//!
//! // For Axum, Actix-web, Rocket, etc.
//! async fn sitemap_handler() -> Vec<u8> {
//! let mut builder = SitemapBuilder::new();
//! builder.add_url(UrlEntry::new("https://example.com/"));
//!
//! // Return compressed bytes (saves 96-98% bandwidth)
//! builder.build_compressed_bytes().unwrap()
//! }
//! ```
//!
//! ## Performance
//!
//! - **Generation Speed**: ~830,000 URLs/second
//! - **Memory Usage**: ~140 bytes per URL during generation, 0 bytes after
//! - **Compression**: 96-98% bandwidth savings with gzip
//! - **Immediate Cleanup**: RAII-based memory management (proven zero leaks)
//!
//! ## Validation
//!
//! Automatic validation includes:
//! - URL format (RFC 3986)
//! - Max 50,000 URLs per standard sitemap (1,000 for news sitemaps)
//! - Max 50MB uncompressed size
//! - Date format (W3C Datetime)
//! - Priority values (0.0 to 1.0)
//! - Video duration, rating, title/description lengths
//! - News language codes (ISO 639), stock tickers (max 5)
//!
//! Disable validation if needed:
//! ```rust
//! use sitemap_generator::SitemapBuilder;
//! let builder = SitemapBuilder::new().validate(false);
//! ```
// Re-export commonly used types
pub use *;
pub use *;
pub use ;
pub use Validator;
pub use SitemapParser;