streaming_crypto/lib.rs
1// ## 📝 streaming-crypto/src/lib.rs
2
3// --- MODULES PUBLISH START ---
4#[cfg(feature = "core-api")]
5pub mod core_api;
6
7#[cfg(feature = "ffi-api")]
8pub mod ffi_api;
9
10#[cfg(feature = "pyo3-api")]
11pub mod pyo3_api;
12// --- MODULES PUBLISH END ---
13
14/// Encrypts data by XORing each byte with 0xAA.
15///
16/// # Examples
17///
18/// ```
19/// use core_api::encrypt;
20///
21/// let data = vec![1, 2, 3];
22/// let encrypted = encrypt(&data);
23/// assert_eq!(encrypted[0], 1 ^ 0xAA);
24#[cfg(feature = "core-api")]
25pub use core_api::encrypt; // re-export the FFI wrapper
26
27/// FFI wrapper for encryption.
28///
29/// # Safety
30/// Returns a raw pointer. Caller must manage memory.
31
32/// FFI wrapper for encryption.
33///
34/// # Safety
35/// This function returns a raw pointer. The caller must manage memory.
36///
37/// # Examples
38///
39/// ```
40/// use std::slice;
41/// use ffi_api::encrypt;
42///
43/// let data = vec![1, 2, 3];
44/// let ptr = encrypt(data.as_ptr(), data.len());
45/// let encrypted = unsafe { slice::from_raw_parts(ptr, data.len()) };
46/// assert_eq!(encrypted[0], 1 ^ 0xAA);
47#[cfg(feature = "ffi-api")]
48pub use ffi_api::encrypt; // re-export the 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::encrypt; // re-export the PyO3 wrapper
69
70#[cfg(feature = "pyo3-api")]
71pub use pyo3_api::streaming_crypto; // re-export the #[pymodule]
72