From 199563550dd41c3dfb703bd3747604a8a03cdbc5 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 11 Jun 2026 14:20:49 +0200 Subject: chore: Remove all `pub`s They will not be marked by rustc/cargo as unused, and as atuin doesn't expose an API all of them _should_ be `pub(crate)` --- crates/turtle/src/atuin_client/encryption.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'crates/turtle/src/atuin_client/encryption.rs') diff --git a/crates/turtle/src/atuin_client/encryption.rs b/crates/turtle/src/atuin_client/encryption.rs index 20a0cd90..f5d4f20d 100644 --- a/crates/turtle/src/atuin_client/encryption.rs +++ b/crates/turtle/src/atuin_client/encryption.rs @@ -11,7 +11,7 @@ use std::{io::prelude::*, path::PathBuf}; use base64::prelude::{BASE64_STANDARD, Engine}; -pub use crypto_secretbox::Key; +pub(crate) use crypto_secretbox::Key; use crypto_secretbox::{ AeadCore, AeadInPlace, KeyInit, XSalsa20Poly1305, aead::{Nonce, OsRng}, @@ -25,19 +25,19 @@ use time::{OffsetDateTime, format_description::well_known::Rfc3339, macros::form use crate::atuin_client::{history::History, settings::Settings}; #[derive(Debug, Serialize, Deserialize)] -pub struct EncryptedHistory { - pub ciphertext: Vec, - pub nonce: Nonce, +pub(crate) struct EncryptedHistory { + pub(crate) ciphertext: Vec, + pub(crate) nonce: Nonce, } -pub fn generate_encoded_key() -> Result<(Key, String)> { +pub(crate) fn generate_encoded_key() -> Result<(Key, String)> { let key = XSalsa20Poly1305::generate_key(&mut OsRng); let encoded = encode_key(&key)?; Ok((key, encoded)) } -pub fn new_key(settings: &Settings) -> Result { +pub(crate) fn new_key(settings: &Settings) -> Result { let path = settings.key_path.as_str(); let path = PathBuf::from(path); @@ -54,7 +54,7 @@ pub fn new_key(settings: &Settings) -> Result { } // Loads the secret key, will create + save if it doesn't exist -pub fn load_key(settings: &Settings) -> Result { +pub(crate) fn load_key(settings: &Settings) -> Result { let path = settings.key_path.as_str(); let key = if PathBuf::from(path).exists() { @@ -67,7 +67,7 @@ pub fn load_key(settings: &Settings) -> Result { Ok(key) } -pub fn encode_key(key: &Key) -> Result { +pub(crate) fn encode_key(key: &Key) -> Result { let mut buf = vec![]; rmp::encode::write_array_len(&mut buf, key.len() as u32) .wrap_err("could not encode key to message pack")?; @@ -80,7 +80,7 @@ pub fn encode_key(key: &Key) -> Result { Ok(buf) } -pub fn decode_key(key: String) -> Result { +pub(crate) fn decode_key(key: String) -> Result { use rmp::decode; let buf = BASE64_STANDARD @@ -118,7 +118,7 @@ pub fn decode_key(key: String) -> Result { } } -pub fn encrypt(history: &History, key: &Key) -> Result { +pub(crate) fn encrypt(history: &History, key: &Key) -> Result { // serialize with msgpack let mut buf = encode(history)?; @@ -133,7 +133,7 @@ pub fn encrypt(history: &History, key: &Key) -> Result { }) } -pub fn decrypt(mut encrypted_history: EncryptedHistory, key: &Key) -> Result { +pub(crate) fn decrypt(mut encrypted_history: EncryptedHistory, key: &Key) -> Result { XSalsa20Poly1305::new(key) .decrypt_in_place( &encrypted_history.nonce, -- cgit v1.3.1