chore: Change from &self to self for RunCommand::run

This commit is contained in:
Awiteb 2024-04-24 23:04:02 +03:00
parent a625f794dd
commit 6666a88cc5
Signed by: awiteb
GPG key ID: 3F6B55640AA6682F
10 changed files with 10 additions and 10 deletions

View file

@ -29,7 +29,7 @@ pub struct Add {
} }
impl RunCommand for Add { impl RunCommand for Add {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self.vault_info.username.is_none() if self.vault_info.username.is_none()
&& self.vault_info.password.is_none() && self.vault_info.password.is_none()
&& self.vault_info.service.is_none() && self.vault_info.service.is_none()

View file

@ -28,7 +28,7 @@ use crate::{
pub struct Clean {} pub struct Clean {}
impl RunCommand for Clean { impl RunCommand for Clean {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
fs::write(vault_manager.vaults_file, "[]").map_err(LprsError::Io) fs::write(vault_manager.vaults_file, "[]").map_err(LprsError::Io)
} }
} }

View file

@ -47,7 +47,7 @@ pub struct Edit {
} }
impl RunCommand for Edit { impl RunCommand for Edit {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
let index = self.index.get() as usize; let index = self.index.get() as usize;
if let Some(vault) = vault_manager.vaults.get_mut(index - 1) { if let Some(vault) = vault_manager.vaults.get_mut(index - 1) {

View file

@ -34,7 +34,7 @@ pub struct Export {
} }
impl RunCommand for Export { impl RunCommand for Export {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self if self
.path .path
.extension() .extension()

View file

@ -45,7 +45,7 @@ pub struct Gen {
} }
impl RunCommand for Gen { impl RunCommand for Gen {
fn run(&self, _vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, _vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self.uppercase || self.lowercase || self.numbers || self.symbols { if self.uppercase || self.lowercase || self.numbers || self.symbols {
println!( println!(
"{}", "{}",

View file

@ -35,7 +35,7 @@ pub struct Import {
} }
impl RunCommand for Import { impl RunCommand for Import {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
if self.path.exists() { if self.path.exists() {
if self if self
.path .path

View file

@ -50,7 +50,7 @@ pub struct List {
} }
impl RunCommand for List { impl RunCommand for List {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()> {
if vault_manager.vaults.is_empty() { if vault_manager.vaults.is_empty() {
return Err(LprsError::Other( return Err(LprsError::Other(
"Looks like there is no passwords to list".to_owned(), "Looks like there is no passwords to list".to_owned(),

View file

@ -35,7 +35,7 @@ pub struct Remove {
} }
impl RunCommand for Remove { impl RunCommand for Remove {
fn run(&self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> { fn run(self, mut vault_manager: Vaults<Plain>) -> LprsResult<()> {
let index = (self.index.get() - 1) as usize; let index = (self.index.get() - 1) as usize;
if index > vault_manager.vaults.len() { if index > vault_manager.vaults.len() {
if !self.force { if !self.force {

View file

@ -63,7 +63,7 @@ macro_rules! create_commands {
#[automatically_derived] #[automatically_derived]
impl $crate::RunCommand for $enum_name{ impl $crate::RunCommand for $enum_name{
fn run(&self, vault_manager: $crate::vault::Vaults<$crate::vault::vault_state::Plain>) -> $crate::LprsResult<()> { fn run(self, vault_manager: $crate::vault::Vaults<$crate::vault::vault_state::Plain>) -> $crate::LprsResult<()> {
match self { match self {
$( $(
Self::$varint(command) => command.run(vault_manager), Self::$varint(command) => command.run(vault_manager),

View file

@ -21,5 +21,5 @@ use crate::{
/// Trait to run the command /// Trait to run the command
pub trait RunCommand { pub trait RunCommand {
fn run(&self, vault_manager: Vaults<Plain>) -> LprsResult<()>; fn run(self, vault_manager: Vaults<Plain>) -> LprsResult<()>;
} }