Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down Expand Up @@ -130,7 +131,7 @@ impl Parcode {
}

/// Loads an object fully into memory from a byte slice.
pub fn load_bytes<T>(data: Vec<u8>) -> Result<T>
pub fn load_bytes<T>(data: impl Into<Arc<Vec<u8>>>) -> Result<T>
where
T: ParcodeNative,
{
Expand All @@ -139,12 +140,15 @@ impl Parcode {

/// Opens a Parcode resource using the configured storage backend.
#[cfg(not(target_arch = "wasm32"))]
pub fn open<P: AsRef<Path>>(path: P) -> Result<ParcodeFile> {
pub fn open<P>(path: P) -> Result<ParcodeFile>
where
P: AsRef<Path>,
{
ParcodeFile::open(path)
}

/// Opens a Parcode resource from a byte slice.
pub fn open_bytes(data: Vec<u8>) -> Result<ParcodeFile> {
pub fn open_bytes(data: impl Into<Arc<Vec<u8>>>) -> Result<ParcodeFile> {
ParcodeFile::from_bytes(data)
}

Expand Down Expand Up @@ -182,7 +186,7 @@ impl Parcode {
}

/// Generates a structural inspection report from a byte slice.
pub fn inspect_bytes(data: Vec<u8>) -> Result<DebugReport> {
pub fn inspect_bytes(data: impl Into<Arc<Vec<u8>>>) -> Result<DebugReport> {
let file = ParcodeFile::from_bytes(data)?;
ParcodeInspector::inspect_file(&file)
}
Expand Down
3 changes: 2 additions & 1 deletion src/graph/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<P>(path: P) -> Result<DebugReport>
where
P: AsRef<Path>,
Expand Down
7 changes: 4 additions & 3 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u8>) -> Result<Self> {
let size = data.len() as u64;
Self::init(DataSource::Memory(Arc::new(data)), size)
pub fn from_bytes(data: impl Into<Arc<Vec<u8>>>) -> Result<Self> {
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<Self> {
Expand Down