Skip to content

Commit

Permalink
Merge pull request #78 from sokorototo/main
Browse files Browse the repository at this point in the history
Maintenance fixes + Changed benchmarks + Small Changes
  • Loading branch information
zeskeertwee authored Jun 14, 2022
2 parents 1bb3753 + be12820 commit f26950d
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 119 deletions.
123 changes: 116 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vach-benchmarks/benches/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn criterion_benchmark(c: &mut Criterion) {
}

// Load data
throughput_group.throughput(Throughput::Bytes((data_1.len() + data_2.len() + data_3.len()) as u64));
throughput_group.throughput(Throughput::Elements(3));

let archive = Archive::with_config(&mut target, &h_config).unwrap();
let mut sink = Sink::new();
Expand Down
4 changes: 2 additions & 2 deletions vach-cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "vach-cli"
version = "0.3.7"
version = "0.4.0"
edition = "2021"
authors = [
"Jasper Fortuin <[email protected]>",
Expand Down Expand Up @@ -29,5 +29,5 @@ pretty_env_logger = "0.4.0"
term_size = "0.3.2"

[dependencies.vach]
path = "../vach"
version = "0.4.0"
features = ["compression", "multithreaded", "crypto"]
12 changes: 8 additions & 4 deletions vach/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ rand = { version = "0.7.0", optional = true }
aes-gcm = { version = "0.9.4", features = ["aes"], optional = true }

# Compression dependencies
lz4_flex = { version = "0.9.2", optional = true }
lz4_flex = { version = "0.9.2", optional = true, default-features = false, features = [
"checked-decode",
"frame"
] }
snap = { version = "1.0.5", optional = true }
brotli = { version = "3.3.4", optional = true }

# Multithreaded feature
# Multithreaded features
parking_lot = { version = "0.12.1", optional = true }
rayon = { version = "1.5.2", optional = true }
num_cpus = { version = "1.13.1", optional = true }

[features]
default = ["builder", "archive"]

archive = []
builder = []
archive = ["parking_lot"]
builder = ["parking_lot"]

crypto = ["ed25519-dalek", "aes-gcm", "rand"]
multithreaded = ["rayon", "num_cpus"]
Expand Down
3 changes: 0 additions & 3 deletions vach/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<p align="center">
<img src="media/logo.png" alt=".vach logo" width="180" height="180">
</p>
<h1 align=center>
<strong>vach</strong>
</h1>
Expand Down
2 changes: 1 addition & 1 deletion vach/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl fmt::Debug for Encryptor {
}

impl Encryptor {
pub(crate) fn new(pk: &PublicKey, magic: [u8; 5]) -> Encryptor {
pub(crate) fn new(pk: &PublicKey, magic: [u8; crate::MAGIC_LENGTH]) -> Encryptor {
// Build encryption key
let bytes = &pk.to_bytes();

Expand Down
2 changes: 1 addition & 1 deletion vach/src/global/compressor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Compressor<T: Read> {
data: T,
}

impl<'a, T: Read> Compressor<T> {
impl<T: Read> Compressor<T> {
/// Construct a new compressor over a read handle
pub fn new(data: T) -> Compressor<T> {
Compressor { data }
Expand Down
2 changes: 1 addition & 1 deletion vach/src/global/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fmt;
use super::{error::InternalError, result::InternalResult};

/// Abstracted flag access and manipulation `struct`.
/// A knock-off minimal bitflags of sorts.
/// A knock-off minimal [bitflags](https://crates.io/crates/bitflags) of sorts.
#[derive(Copy, Clone, Default, PartialEq)]
pub struct Flags {
pub(crate) bits: u32,
Expand Down
10 changes: 5 additions & 5 deletions vach/src/global/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ArchiveConfig {
#[inline(always)]
#[cfg(feature = "crypto")]
#[cfg_attr(docsrs, doc(cfg(feature = "crypto")))]
pub const fn new(magic: [u8; 5], key: Option<crypto::PublicKey>) -> ArchiveConfig {
pub const fn new(magic: [u8; crate::MAGIC_LENGTH], key: Option<crypto::PublicKey>) -> ArchiveConfig {
ArchiveConfig { magic, public_key: key }
}

Expand All @@ -37,7 +37,7 @@ impl ArchiveConfig {
/// let config = ArchiveConfig::new(*b"_TEST");
/// ```
#[cfg(not(feature = "crypto"))]
pub const fn new(magic: [u8; 5]) -> ArchiveConfig {
pub const fn new(magic: [u8; crate::MAGIC_LENGTH]) -> ArchiveConfig {
ArchiveConfig { magic }
}

Expand Down Expand Up @@ -71,7 +71,7 @@ impl ArchiveConfig {
}

/// Setter for the magic into a [ArchiveConfig]
pub fn magic(mut self, magic: [u8; 5]) -> ArchiveConfig {
pub fn magic(mut self, magic: [u8; crate::MAGIC_LENGTH]) -> ArchiveConfig {
self.magic = magic;
self
}
Expand Down Expand Up @@ -172,9 +172,9 @@ impl Header {
// Construct header
Ok(Header {
// Read magic, [u8;5]
magic: buffer[0..5].try_into().unwrap(),
magic: buffer[0..crate::MAGIC_LENGTH].try_into().unwrap(),
// Read flags, u32 from [u8;4]
flags: Flags::from_bits(u32::from_le_bytes(buffer[5..9].try_into().unwrap())),
flags: Flags::from_bits(u32::from_le_bytes(buffer[crate::MAGIC_LENGTH..9].try_into().unwrap())),
// Read version, u16 from [u8;2]
arch_version: u16::from_le_bytes(buffer[9..11].try_into().unwrap()),
// Read the capacity of the archive, u16 from [u8;2]
Expand Down
12 changes: 8 additions & 4 deletions vach/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
/*!
#### A simple archiving format, designed for storing assets in compact secure containers
`vach`, pronounced like "puck" but with a "v", is an archiving and resource transmission format. It was built to be secure, contained and protected. It was, in fact, designed by the [SCP](https://en.wikipedia.org/wiki/SCP_Foundation) to keep your anomalous assets compact and secure during transmission. A big benefit of `vach` is the fine grained control it grants it's users, as it allows for per-entry independent configuration.`vach` also has in-built support for multiple compression schemes (LZ4, Snappy and Brolti), [data signing](https://github.com/dalek-cryptography/ed25519-dalek), leaf [bitflags](https://docs.rs/vach/latest/vach/archive/struct.Flags.html), [encryption](https://docs.rs/aes-gcm/latest/aes_gcm/) and some degree of archive customization. Check out the `vach` spec at **[spec.txt](https://github.com/zeskeertwee/vach/blob/main/spec/main.txt)**. Any and *all* help will be much appreciated, especially proof reading the docs and code review.
`vach` is an archiving and resource transmission format.
It was built to be secure, contained and protected. A big benefit of `vach` is the fine grained control it grants it's users, as it allows for per-entry independent configuration.
`vach` also has in-built support for multiple compression schemes (LZ4, Snappy and Brolti), [data signing](https://github.com/dalek-cryptography/ed25519-dalek), leaf [bitflags](https://docs.rs/vach/latest/vach/archive/struct.Flags.html), [encryption](https://docs.rs/aes-gcm/latest/aes_gcm/) and some degree of archive customization.
> Check out the `vach` spec at **[spec.txt](https://github.com/zeskeertwee/vach/blob/main/spec/main.txt)**.
### 👄 Terminologies
Expand Down Expand Up @@ -168,12 +172,12 @@ pub const SIGNATURE_LENGTH: usize = 64;
/// Maximum size for any ID
pub const MAX_ID_LENGTH: usize = 65535; // u16::MAX

/// The default MAGIC used by `vach`
pub const DEFAULT_MAGIC: &[u8; 5] = b"VfACH";

/// The standard size of any MAGIC entry in bytes
pub const MAGIC_LENGTH: usize = 5;

/// The default MAGIC used by `vach`
pub const DEFAULT_MAGIC: &[u8; crate::MAGIC_LENGTH] = b"VfACH";

/// Consolidated import for crate logic; This module stores all `structs` associated with this crate. Constants can be accesses [directly](#constants) with `crate::<CONSTANT>`
pub mod prelude {
pub use crate::global::{
Expand Down
Loading

0 comments on commit f26950d

Please sign in to comment.