refactor: replace base64_stream with base64

the base64_stream is not required anymore as the base64 crate also
contains a streaming interface
This commit is contained in:
Moritz Bitsch 2024-04-03 09:31:48 +02:00
parent 5876b6295f
commit df43a24a37
No known key found for this signature in database
3 changed files with 15 additions and 103 deletions

99
Cargo.lock generated
View file

@ -4,106 +4,13 @@ version = 3
[[package]] [[package]]
name = "base64" name = "base64"
version = "0.21.7" version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" checksum = "9475866fec1451be56a3c2400fd081ff546538961565ccb5b7142cbd22bc7a51"
[[package]]
name = "base64-stream"
version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b17698d5fd7ede49ee2bbc32d6c35288376b1465f6046088370fce74f2240548"
dependencies = [
"base64",
"educe",
"generic-array",
]
[[package]]
name = "educe"
version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4bd92664bf78c4d3dba9b7cdafce6fa15b13ed3ed16175218196942e99168a8"
dependencies = [
"enum-ordinalize",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "enum-ordinalize"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fea0dcfa4e54eeb516fe454635a95753ddd39acda650ce703031c6973e315dd5"
dependencies = [
"enum-ordinalize-derive",
]
[[package]]
name = "enum-ordinalize-derive"
version = "4.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d28318a75d4aead5c4db25382e8ef717932d0346600cacae6357eb5941bc5ff"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "generic-array"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe739944a5406424e080edccb6add95685130b9f160d5407c639c7df0c5836b0"
dependencies = [
"typenum",
]
[[package]] [[package]]
name = "osclip" name = "osclip"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"base64-stream", "base64",
] ]
[[package]]
name = "proc-macro2"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
[[package]]
name = "syn"
version = "2.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "typenum"
version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"

View file

@ -1,10 +1,10 @@
[package] [package]
name = "osclip" name = "osclip"
version = "0.1.0" version = "0.1.1"
edition = "2021" edition = "2021"
description = "small utility to copy text from terminal to system clipboard" description = "small utility to copy text from terminal to system clipboard"
license = "ISC" license = "ISC"
repository = "https://git.h6t.eu/madmo/osclip" repository = "https://git.h6t.eu/madmo/osclip"
[dependencies] [dependencies]
base64-stream = "3.0.1" base64 = "0.22.0"

View file

@ -1,12 +1,17 @@
use std::io::{Result, Write}; use std::io::{Result, Write};
fn main() -> Result<()> { fn main() -> Result<()> {
std::io::stdout().write_all(&[0x1b, 0x5d])?; let mut stdout = std::io::stdout().lock();
std::io::stdout().write_all(b"52;c;")?;
stdout.write_all(&[0x1b, 0x5d])?;
stdout.write_all(b"52;c;")?;
let mut writer =
base64::write::EncoderWriter::new(stdout, &base64::engine::general_purpose::STANDARD);
let mut writer = base64_stream::ToBase64Writer::new(std::io::stdout());
std::io::copy(&mut std::io::stdin(), &mut writer)?; std::io::copy(&mut std::io::stdin(), &mut writer)?;
writer.flush()?;
std::io::stdout().write_all(&[0x07, 0x0a]) stdout = writer.finish()?;
stdout.write_all(&[0x07, 0x0a])
} }