Fixed unused imports and variables

This commit is contained in:
Sameh Abouel-saad
2025-05-29 13:41:10 +03:00
parent b0b6359be1
commit b82d457873
11 changed files with 31 additions and 24 deletions

View File

@@ -9,7 +9,7 @@ use crate::session::SessionManager;
#[cfg(not(target_arch = "wasm32"))]
pub fn register_rhai_api<S: kvstore::traits::KVStore + Send + Sync + Clone + 'static>(
engine: &mut Engine,
session_manager: std::sync::Arc<std::sync::Mutex<SessionManager<S>>>,
_session_manager: std::sync::Arc<std::sync::Mutex<SessionManager<S>>>,
) {
engine.register_type::<RhaiSessionManager<S>>();
engine.register_fn("select_keypair", RhaiSessionManager::<S>::select_keypair);
@@ -37,7 +37,7 @@ impl<S: kvstore::traits::KVStore + Send + Sync + Clone + 'static> RhaiSessionMan
// Use Mutex for interior mutability, &self is sufficient
self.inner.lock().unwrap().select_keypair(&key_id).map_err(|e| format!("select_keypair error: {e}"))
}
pub fn select_default_keypair(&self) -> Result<(), String> {
self.inner.lock().unwrap().select_default_keypair()
.map_err(|e| format!("select_default_keypair error: {e}"))

View File

@@ -3,7 +3,6 @@
//! All state is local to the SessionManager instance. No global state.
use crate::{KVStore, KeyEntry, KeyspaceData, Vault, VaultError};
use std::collections::HashMap;
use zeroize::Zeroize;
/// SessionManager: Ergonomic, stateful wrapper over the Vault stateless API.
@@ -130,17 +129,17 @@ impl<S: KVStore + Send + Sync> SessionManager<S> {
self.current_keyspace()
.and_then(|ks| ks.keypairs.first())
}
/// Selects the default keypair (first keypair) as the current keypair.
pub fn select_default_keypair(&mut self) -> Result<(), VaultError> {
let default_id = self
.default_keypair()
.map(|k| k.id.clone())
.ok_or_else(|| VaultError::Crypto("No default keypair found".to_string()))?;
self.select_keypair(&default_id)
}
/// Returns true if the current keypair is the default keypair (first keypair).
pub fn is_default_keypair_selected(&self) -> bool {
match (self.current_keypair(), self.default_keypair()) {
@@ -312,17 +311,17 @@ impl<S: KVStore> SessionManager<S> {
self.current_keyspace()
.and_then(|ks| ks.keypairs.first())
}
/// Selects the default keypair (first keypair) as the current keypair.
pub fn select_default_keypair(&mut self) -> Result<(), VaultError> {
let default_id = self
.default_keypair()
.map(|k| k.id.clone())
.ok_or_else(|| VaultError::Crypto("No default keypair found".to_string()))?;
self.select_keypair(&default_id)
}
/// Returns true if the current keypair is the default keypair (first keypair).
pub fn is_default_keypair_selected(&self) -> bool {
match (self.current_keypair(), self.default_keypair()) {