From 7680096ad4badd35bee2489fcbf85afa3750b542 Mon Sep 17 00:00:00 2001 From: Retype15 Date: Wed, 31 Dec 2025 00:49:36 -0500 Subject: [PATCH] feat: All _bytes methods that uses from_bytes updated to accept Arc directly. Deleted 'standard' feature and now is default feature that implement ["parallel", "mmap"] --- Cargo.toml | 3 +-- README.md | 2 ++ src/api.rs | 12 ++++++++---- src/graph/job.rs | 3 ++- src/inspector.rs | 2 +- src/reader.rs | 7 ++++--- 6 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 514e0d3..0d9f452 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,8 +34,7 @@ memmap2 = { version = "0.9.9", optional = true } lz4_flex = { version = "0.12.0", optional = true } [features] -default = ["standard"] -standard = ["parallel", "mmap"] +default = ["parallel", "mmap"] parallel = ["dep:rayon"] mmap = ["dep:memmap2"] lz4_flex = ["dep:lz4_flex"] diff --git a/README.md b/README.md index 8935525..1c94fd1 100644 --- a/README.md +++ b/README.md @@ -242,6 +242,8 @@ Root Offset: 550368 └── [Map Container] Size: 4b | Algo: None | Children: 4 [Hashtable with 4 buckets] ``` +**Note**: `Algo` means compression algorithm. + --- ## Macro Attributes Reference diff --git a/src/api.rs b/src/api.rs index 2aa990f..ebd1a44 100644 --- a/src/api.rs +++ b/src/api.rs @@ -71,6 +71,7 @@ use crate::reader::{ParcodeFile, ParcodeNative}; use crate::visitor::ParcodeVisitor; use std::io::Write; use std::path::Path; +use std::sync::Arc; /// The main entry point for Parcode. /// @@ -130,7 +131,7 @@ impl Parcode { } /// Loads an object fully into memory from a byte slice. - pub fn load_bytes(data: Vec) -> Result + pub fn load_bytes(data: impl Into>>) -> Result where T: ParcodeNative, { @@ -139,12 +140,15 @@ impl Parcode { /// Opens a Parcode resource using the configured storage backend. #[cfg(not(target_arch = "wasm32"))] - pub fn open>(path: P) -> Result { + pub fn open

(path: P) -> Result + where + P: AsRef, + { ParcodeFile::open(path) } /// Opens a Parcode resource from a byte slice. - pub fn open_bytes(data: Vec) -> Result { + pub fn open_bytes(data: impl Into>>) -> Result { ParcodeFile::from_bytes(data) } @@ -182,7 +186,7 @@ impl Parcode { } /// Generates a structural inspection report from a byte slice. - pub fn inspect_bytes(data: Vec) -> Result { + pub fn inspect_bytes(data: impl Into>>) -> Result { let file = ParcodeFile::from_bytes(data)?; ParcodeInspector::inspect_file(&file) } diff --git a/src/graph/job.rs b/src/graph/job.rs index e456911..8381658 100644 --- a/src/graph/job.rs +++ b/src/graph/job.rs @@ -8,7 +8,8 @@ pub struct JobConfig { /// Compression algorithm ID. /// 0 = No Compression (Default) /// 1 = Lz4 (if feature enabled) - /// 2..255 = Reserved + /// 0..16 = Reserved + /// 17..255 = Custom pub compression_id: u8, /// Whether to use the optimized Map Sharding strategy. pub is_map: bool, diff --git a/src/inspector.rs b/src/inspector.rs index 1cc8daa..784af44 100644 --- a/src/inspector.rs +++ b/src/inspector.rs @@ -67,7 +67,7 @@ impl ParcodeInspector { }) } - /// Convenience wrapper to inspect from path (matches old API if needed). + /// Convenience wrapper to inspect from path. pub fn inspect

(path: P) -> Result where P: AsRef, diff --git a/src/reader.rs b/src/reader.rs index fc5e506..82119b1 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -644,9 +644,10 @@ impl ParcodeFile { /// /// This is the primary entry point for tests and architectures without direct file access. /// The `ParcodeFile` takes ownership of the data (wrapped in Arc). - pub fn from_bytes(data: Vec) -> Result { - let size = data.len() as u64; - Self::init(DataSource::Memory(Arc::new(data)), size) + pub fn from_bytes(data: impl Into>>) -> Result { + let data_arc = data.into(); + let size = data_arc.len() as u64; + Self::init(DataSource::Memory(data_arc), size) } fn init(source: DataSource, file_size: u64) -> Result {