Skip to content

Commit

Permalink
Add: Default trait for Nvt. Also fix the new() to retunr the initiali…
Browse files Browse the repository at this point in the history
…zed Nvt. Adjust format.
  • Loading branch information
jjnicola committed Nov 23, 2022
1 parent 8980341 commit 3893694
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions rust/nvtcache/src/nvt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ pub struct Nvt {
family: String,
}

pub trait Default {
fn default() -> Nvt;
}

impl Default for Nvt {
fn default() -> Nvt {
Nvt {
Expand Down Expand Up @@ -165,7 +169,7 @@ impl Default for Nvt {
impl Nvt {
/// Nvt constructor
pub fn new() -> Result<Nvt> {
Ok(Nvt::default())
return Ok(Nvt::default());
}

pub fn destroy(self) {}
Expand Down Expand Up @@ -348,7 +352,14 @@ impl Nvt {
if self.tag.is_empty() {
self.tag = [name, "=".to_string(), new_value].concat();
} else {
self.tag = [current_tag.to_string(), "|".to_string(), name, "=".to_string(), new_value].concat();
self.tag = [
current_tag.to_string(),
"|".to_string(),
name,
"=".to_string(),
new_value,
]
.concat();
}

return Ok(());
Expand Down

0 comments on commit 3893694

Please sign in to comment.