camo/lib.rs
1//! # camo
2//!
3//! A Rust library for generating Camo-compatible signed URLs.
4//!
5//! Camo is an SSL image proxy that routes images through HTTPS to prevent
6//! mixed content warnings on secure pages.
7//!
8//! ## Quick Start
9//!
10//! ```rust
11//! use camo::CamoUrl;
12//!
13//! let camo = CamoUrl::new("your-secret-key");
14//!
15//! // Generate a signed URL
16//! let signed_url = camo.sign("http://example.com/image.png");
17//! println!("{}", signed_url.to_url("https://camo.example.com"));
18//! // Output: https://camo.example.com/abc123.../68747470...
19//!
20//! // Or use the builder pattern
21//! let url = camo.sign("http://example.com/image.png")
22//! .base64()
23//! .to_url("https://camo.example.com");
24//! ```
25//!
26//! ## URL Formats
27//!
28//! The library supports two encoding formats:
29//!
30//! - **Hex** (default): URL is encoded as hexadecimal
31//! - **Base64**: URL is encoded as URL-safe base64
32//!
33//! Generated URLs follow the format: `<base>/<digest>/<encoded_url>`
34
35#[cfg(all(feature = "server", feature = "worker"))]
36compile_error!("Features 'server' and 'worker' are mutually exclusive. Please enable only one.");
37
38mod utils;
39
40#[cfg(any(feature = "server", feature = "worker"))]
41pub mod server;
42
43#[cfg(feature = "worker")]
44mod worker;
45#[cfg(feature = "worker")]
46pub use worker::*;
47
48#[cfg(feature = "client")]
49mod camo;
50#[cfg(feature = "client")]
51pub use camo::{CamoUrl, Encoding, SignedUrl};