diff --git a/Cargo.lock b/Cargo.lock index b5e9c68..62becbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -232,12 +232,6 @@ dependencies = [ "backtrace", ] -[[package]] -name = "base16ct" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" - [[package]] name = "base64" version = "0.21.7" @@ -250,6 +244,12 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" +[[package]] +name = "base64ct" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" + [[package]] name = "bitflags" version = "2.6.0" @@ -1657,7 +1657,7 @@ name = "streamstore-cli" version = "0.7.0" dependencies = [ "async-stream", - "base16ct", + "base64ct", "clap", "color-print", "colored", diff --git a/Cargo.toml b/Cargo.toml index f877881..309d762 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ path = "src/main.rs" [dependencies] async-stream = "0.3.6" -base16ct = { version = "0.2.0", features = ["alloc"] } +base64ct = { version = "1.6.0", features = ["alloc"] } clap = { version = "4.5.20", features = ["derive"] } color-print = "0.3.6" colored = "2.1.0" diff --git a/src/main.rs b/src/main.rs index 29eb1df..982c9c8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,7 @@ use std::{ }; use account::AccountService; +use base64ct::{Base64, Encoding}; use basin::BasinService; use clap::{builder::styling, Parser, Subcommand}; use colored::*; @@ -213,7 +214,7 @@ enum Commands { /// and any regression will be ignored. trim_point: u64, - /// Enforce fencing token specified in hex. + /// Enforce fencing token specified in base64. #[arg(short = 'f', long, value_parser = parse_fencing_token)] fencing_token: Option, @@ -233,12 +234,12 @@ enum Commands { #[arg(value_name = "S2_URI")] uri: S2BasinAndStreamUri, - /// New fencing token specified in hex. + /// New fencing token specified in base64. /// It may be upto 16 bytes, and can be empty. #[arg(value_parser = parse_fencing_token)] new_fencing_token: FencingToken, - /// Enforce existing fencing token, specified in hex. + /// Enforce existing fencing token, specified in base64. #[arg(short = 'f', long, value_parser = parse_fencing_token)] fencing_token: Option, @@ -254,7 +255,7 @@ enum Commands { #[arg(value_name = "S2_URI")] uri: S2BasinAndStreamUri, - /// Enforce fencing token specified in hex. + /// Enforce fencing token specified in base64. #[arg(short = 'f', long, value_parser = parse_fencing_token)] fencing_token: Option, @@ -410,8 +411,8 @@ fn parse_records_output_source(s: &str) -> Result { } fn parse_fencing_token(s: &str) -> Result { - base16ct::mixed::decode_vec(s) - .map_err(|_| "invalid hex")? + Base64::decode_vec(s) + .map_err(|_| "invalid base64")? .try_into() } @@ -860,7 +861,10 @@ async fn run() -> Result<(), S2CliError> { let (cmd, description) = match command_record { CommandRecord::Fence { fencing_token } => ( "fence", - format!("FencingToken({})", base16ct::lower::encode_string(fencing_token.as_ref())), + format!( + "FencingToken({})", + Base64::encode_string(fencing_token.as_ref()), + ), ), CommandRecord::Trim { seq_num } => ( "trim",