praborrow_logistics/
lib.rs

1//! Zero-copy buffer abstraction for raw byte streams.
2//!
3//! Provides `RawResource` for managing raw byte buffers without allocation overhead.
4//! Uses `ManuallyDrop` to take ownership of data while exposing raw pointers.
5//!
6//! # Safety
7//! Caller is responsible for ensuring the buffer outlives all references to it.
8
9use std::mem::ManuallyDrop;
10
11/// A zero-copy buffer resource representing "Hilirisasi Data" (Downstreaming Data).
12/// 
13/// This struct holds a raw pointer to data that is NOT owned by this struct in the
14/// traditional sense (or rather, ownership is manually managed).
15pub struct RawResource {
16    pub ptr: *const u8,
17    pub len: usize,
18}
19
20impl RawResource {
21    /// HILIRISASI DATA: Refines raw data into a downstreamable resource.
22    /// 
23    /// We take ownership of a Vec<u8>, wrap it in ManuallyDrop, and extract the pointer.
24    pub fn refine(data: Vec<u8>) -> Self {
25        let mut domesticated = ManuallyDrop::new(data);
26        Self {
27            ptr: domesticated.as_mut_ptr() as *const u8,
28            len: domesticated.len(),
29        }
30    }
31}