-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f5c57dc
commit b6b7dc4
Showing
9 changed files
with
437 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use clap::ValueEnum; | ||
use zap::compression::CompressionType; | ||
|
||
|
||
|
||
#[derive(Debug, Clone, ValueEnum)] | ||
pub enum CompressionLevel{ | ||
Fastest, | ||
Best, | ||
Default, | ||
} | ||
|
||
impl From<String> for CompressionLevel { | ||
fn from(s: String) -> Self { | ||
match s.as_str() { | ||
"fastest" => CompressionLevel::Fastest, | ||
"best" => CompressionLevel::Best, | ||
_ => CompressionLevel::Default, | ||
} | ||
} | ||
} | ||
|
||
impl Into<flate2::Compression> for CompressionLevel { | ||
fn into(self) -> flate2::Compression { | ||
match self { | ||
CompressionLevel::Fastest => flate2::Compression::fast(), | ||
CompressionLevel::Best => flate2::Compression::best(), | ||
CompressionLevel::Default => flate2::Compression::default(), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Default, Debug, Clone, ValueEnum)] | ||
pub enum BinCompressionType { | ||
Passthrough, | ||
#[default] | ||
Lz4, | ||
Gzip, | ||
Snappy, | ||
} | ||
|
||
impl From<String> for BinCompressionType { | ||
fn from(s: String) -> Self { | ||
match s.as_str() { | ||
"passthrough" => Self::Passthrough, | ||
"lz4" => Self::Lz4, | ||
"gzip" => Self::Gzip, | ||
"snappy" => Self::Snappy, | ||
"" => Self::default(), | ||
_ => Self::Passthrough, | ||
} | ||
} | ||
} | ||
|
||
impl From<CompressionType> for BinCompressionType { | ||
fn from(e: CompressionType) -> Self { | ||
match e { | ||
CompressionType::Passthrough => Self::Passthrough, | ||
CompressionType::Lz4 => Self::Lz4, | ||
CompressionType::Gzip => Self::Gzip, | ||
CompressionType::Snappy => Self::Snappy, | ||
} | ||
} | ||
} | ||
|
||
impl Into<CompressionType> for BinCompressionType { | ||
fn into(self) -> CompressionType { | ||
match self { | ||
BinCompressionType::Passthrough => CompressionType::Passthrough, | ||
BinCompressionType::Lz4 => CompressionType::Lz4, | ||
BinCompressionType::Gzip => CompressionType::Gzip, | ||
BinCompressionType::Snappy => CompressionType::Snappy, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,47 @@ | ||
use clap::ValueEnum; | ||
use zap::encryption::EncryptionType; | ||
|
||
// Consider moving | ||
#[derive(Debug, Clone, ValueEnum)] | ||
pub enum SecretType { | ||
Password, | ||
Key | ||
#[derive(Debug, Default, Clone, ValueEnum)] | ||
pub enum BinEncryptionType { | ||
Passthrough, | ||
#[default] | ||
XChaCha, | ||
AesGcm, | ||
ChaCha, | ||
} | ||
|
||
impl From<String> for BinEncryptionType { | ||
fn from(s: String) -> Self { | ||
match s.as_str() { | ||
"passthrough" => Self::Passthrough, | ||
"xchacha" => Self::XChaCha, | ||
"aesgcm" => Self::AesGcm, | ||
"chacha" => Self::ChaCha, | ||
"" => Self::default(), | ||
_ => Self::Passthrough, | ||
} | ||
} | ||
} | ||
|
||
impl From<EncryptionType> for BinEncryptionType { | ||
fn from(e: EncryptionType) -> Self { | ||
match e { | ||
EncryptionType::Passthrough => Self::Passthrough, | ||
EncryptionType::XChaCha => Self::XChaCha, | ||
EncryptionType::AesGcm => Self::AesGcm, | ||
EncryptionType::ChaCha => Self::ChaCha, | ||
} | ||
} | ||
} | ||
|
||
impl Into<EncryptionType> for BinEncryptionType { | ||
fn into(self) -> EncryptionType { | ||
match self { | ||
BinEncryptionType::Passthrough => EncryptionType::Passthrough, | ||
BinEncryptionType::XChaCha => EncryptionType::XChaCha, | ||
BinEncryptionType::AesGcm => EncryptionType::AesGcm, | ||
BinEncryptionType::ChaCha => EncryptionType::ChaCha, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.