Crates.io | lusl |
lib.rs | lusl |
version | 2.1.0 |
source | src |
created_at | 2022-11-15 20:14:21.557946 |
updated_at | 2023-02-04 09:32:36.392807 |
description | Lossless Uncompressed Serializer Library |
homepage | |
repository | https://github.com/altair823/LUSL |
max_upload_size | |
id | 715928 |
size | 5,020,974 |
lusl
is a library that serializes a directory containing multiple files into a single file and also deserializes it, like a tarball.
The encryption is done using XChaCha20-Poly1305 and the compression is done using zlib.
See documents.
use lusl::{Serializer, Deserializer, SerializeOption};
use std::path::PathBuf;
// Serialize a directory into a file.
let original = PathBuf::from("tests");
let result = PathBuf::from("serialized.bin");
let mut serializer = Serializer::new(&original, &result).unwrap();
serializer.serialize().unwrap();
// Deserialize the file into a directory.
let restored = PathBuf::from("deserialized_dir");
let mut deserializer = Deserializer::new(&result, &restored).unwrap();
deserializer.deserialize().unwrap();
assert!(&result.is_file());
assert!(&restored.is_dir());
use lusl::{Serializer, Deserializer, SerializeOption};
use std::path::PathBuf;
// Serialize a directory into a file.
let original = PathBuf::from("tests");
let result = PathBuf::from("serialized.bin");
let mut serializer = Serializer::new(&original, &result).unwrap();
// Set the encryption key and compression option.
serializer.set_option(SerializeOption::new().to_encrypt("password").to_compress(true));
serializer.serialize().unwrap();
// Deserialize the file into a directory.
let restored = PathBuf::from("deserialized_dir");
let mut deserializer = Deserializer::new(&result, &restored).unwrap();
// Set the encryption key and compression option.
deserializer.set_option(SerializeOption::new().to_encrypt("password").to_compress(true));
deserializer.deserialize().unwrap();
assert!(&result.is_file());
assert!(&restored.is_dir());
If you want to run test codes(like cargo test
), must not run parallel test.
It cause multiple error because all test codes were written without assuming parallel tests.
To run test, run code below.
cargo test -- --test-threads=1