streaming_crypto/lib.rs
1// ## 📝 streaming-crypto/src/lib.rs
2
3// --- MODULES DYNAMIC START ---
4#[cfg(feature = "core-api")] pub mod core_api;
5#[cfg(feature = "ffi-api")] pub mod ffi_api;
6#[cfg(feature = "pyo3-api")] pub mod pyo3_api;
7
8// --- MODULES DYNAMIC END ---
9
10/// Encrypts data by XORing each byte with 0xAA.
11///
12/// # Examples
13///
14/// ```
15/// use streaming_crypto::encrypt;
16///
17/// let data = vec![1, 2, 3];
18/// let encrypted = encrypt(&data);
19/// assert_eq!(encrypted[0], 1 ^ 0xAA);
20/// assert_eq!(encrypted[1], 2 ^ 0xAA);
21/// assert_eq!(encrypted[2], 3 ^ 0xAA);
22/// ```
23#[cfg(feature = "core-api")]
24pub use core_api::*; // re-export everything from core_api
25
26/// FFI wrapper for encryption.
27///
28/// # Safety
29/// Returns a raw pointer. Caller must manage memory.
30///
31/// FFI wrapper for encryption.
32///
33/// # Safety
34/// This function returns a raw pointer. The caller must manage memory.
35///
36/// # Examples
37///
38/// ```
39/// use std::slice;
40/// use ffi_api::encrypt;
41///
42/// let data = vec![1, 2, 3];
43/// let ptr = encrypt(data.as_ptr(), data.len());
44/// let encrypted = unsafe { slice::from_raw_parts(ptr, data.len()) };
45/// assert_eq!(encrypted[0], 1 ^ 0xAA);
46/// ```
47#[cfg(feature = "ffi-api")]
48pub use ffi_api::*; // re-export everything from FFI wrapper
49
50/// # Examples
51///
52/// ```
53/// use pyo3::prelude::*;
54/// use pyo3_api::encrypt;
55/// use pyo3::types::PyBytes;
56///
57/// Python::with_gil(|py| {
58/// let data = PyBytes::new_bound(py, &[1, 2, 3]);
59///
60/// let encrypted = encrypt(py, &data).unwrap();
61///
62/// assert_eq!(encrypted[0], 1 ^ 0xAA);
63/// assert_eq!(encrypted[1], 2 ^ 0xAA);
64/// assert_eq!(encrypted[2], 3 ^ 0xAA);
65/// });
66/// ```
67#[cfg(feature = "pyo3-api")]
68pub use pyo3_api::*; // re-export everything from PyO3 wrapper