Skip to content

Commit

Permalink
Remove From<(&str, &str, &NaslValue)> impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Nov 7, 2024
1 parent 0fd0f0e commit 31e16d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 18 deletions.
4 changes: 3 additions & 1 deletion rust/src/nasl/builtin/cryptographic/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use sha2::{Sha256, Sha512};
use crate::nasl::syntax::NaslValue;
use crate::nasl::utils::{Context, Register};

use super::ArgumentError;

fn nasl_hash<D: Digest>(register: &Register) -> Result<NaslValue, FunctionErrorKind>
where
D::OutputSize: std::ops::Add,
Expand All @@ -28,7 +30,7 @@ where
NaslValue::String(x) => x.as_bytes(),
NaslValue::Data(x) => x,
NaslValue::Null => return Ok(NaslValue::Null),
x => return Err(("data", "string", x).into()),
x => return Err(ArgumentError::wrong_argument("data", "string", &x.to_string()).into()),
};

let mut hash = D::new();
Expand Down
17 changes: 0 additions & 17 deletions rust/src/nasl/utils/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,3 @@ impl FunctionErrorKind {
Self::Argument(ArgumentError::MissingNamed(vec![val.to_string()]))
}
}

impl From<(&str, &str, &NaslValue)> for FunctionErrorKind {
fn from(value: (&str, &str, &NaslValue)) -> Self {
let (key, expected, got) = value;
let got: &str = &got.to_string();
ArgumentError::wrong_argument(key, expected, got).into()
}
}

impl From<(&str, &str, Option<&NaslValue>)> for FunctionErrorKind {
fn from(value: (&str, &str, Option<&NaslValue>)) -> Self {
match value {
(key, expected, Some(x)) => (key, expected, x).into(),
(key, expected, None) => ArgumentError::wrong_argument(key, expected, "NULL").into(),
}
}
}

0 comments on commit 31e16d5

Please sign in to comment.