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/// ```
25#[cfg(feature = "core-api")]
26pub use core_api::encrypt; // re-export the FFI wrapper
27
28// /// FFI wrapper for encryption.
29// ///
30// /// # Safety
31// /// Returns a raw pointer. Caller must manage memory.
32// ///
33// /// FFI wrapper for encryption.
34// ///
35// /// # Safety
36// /// This function returns a raw pointer. The caller must manage memory.
37// ///
38// /// # Examples
39// ///
40// /// ```
41// /// use std::slice;
42// /// use ffi_api::encrypt;
43// ///
44// /// let data = vec![1, 2, 3];
45// /// let ptr = encrypt(data.as_ptr(), data.len());
46// /// let encrypted = unsafe { slice::from_raw_parts(ptr, data.len()) };
47// /// assert_eq!(encrypted[0], 1 ^ 0xAA);
48// /// ```
49// #[cfg(feature = "ffi-api")]
50// pub use ffi_api::encrypt; // re-export the FFI wrapper
51
52// /// # Examples
53// ///
54// /// ```
55// /// use pyo3::prelude::*;
56// /// use pyo3_api::encrypt;
57// /// use pyo3::types::PyBytes;
58// ///
59// /// Python::with_gil(|py| {
60// /// let data = PyBytes::new_bound(py, &[1, 2, 3]);
61// ///
62// /// let encrypted = encrypt(py, &data).unwrap();
63// ///
64// /// assert_eq!(encrypted[0], 1 ^ 0xAA);
65// /// assert_eq!(encrypted[1], 2 ^ 0xAA);
66// /// assert_eq!(encrypted[2], 3 ^ 0xAA);
67// /// });
68// /// ```
69// #[cfg(feature = "pyo3-api")]
70// pub use pyo3_api::encrypt; // re-export the PyO3 wrapper
71
72// #[cfg(feature = "pyo3-api")]
73// pub use pyo3_api::streaming_crypto; // re-export the #[pymodule]