-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #617 from GDATASoftwareAG/rust/from_buf
add for_buf function
- Loading branch information
Showing
8 changed files
with
118 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,13 @@ | ||
use crate::message::kind::Kind; | ||
use crate::{error::VResult, sha256::Sha256}; | ||
use serde::{Deserialize, Serialize}; | ||
use crate::error::VResult; | ||
use serde::Serialize; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct VerdictRequest { | ||
pub sha256: String, | ||
pub kind: Kind, | ||
pub guid: String, | ||
pub session_id: String, | ||
pub use_hash_lookup: bool, | ||
pub use_cache: bool, | ||
} | ||
|
||
impl VerdictRequest { | ||
pub fn new(sha256: &Sha256, session_id: String, use_cache: bool, use_hash_lookup: bool) -> Self { | ||
Self { | ||
guid: uuid::Uuid::new_v4().to_string(), | ||
sha256: sha256.to_string(), | ||
kind: Kind::VerdictRequest, | ||
session_id, | ||
use_cache, | ||
use_hash_lookup, | ||
} | ||
} | ||
|
||
pub fn to_json(&self) -> VResult<String> { | ||
pub trait VerdictRequest { | ||
fn to_json(&self) -> VResult<String> | ||
where | ||
Self: Serialize, | ||
{ | ||
serde_json::to_string(self).map_err(|e| e.into()) | ||
} | ||
pub fn guid(&self) -> &str { | ||
&self.guid | ||
} | ||
|
||
fn guid(&self) -> &str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::message::kind::Kind; | ||
use crate::sha256::Sha256; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::VerdictRequest; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct VerdictRequestFile { | ||
pub sha256: String, | ||
pub kind: Kind, | ||
pub guid: String, | ||
pub session_id: String, | ||
pub use_hash_lookup: bool, | ||
pub use_cache: bool, | ||
} | ||
|
||
impl VerdictRequestFile { | ||
pub fn new( | ||
sha256: &Sha256, | ||
session_id: String, | ||
use_cache: bool, | ||
use_hash_lookup: bool, | ||
) -> Self { | ||
Self { | ||
guid: uuid::Uuid::new_v4().to_string(), | ||
sha256: sha256.to_string(), | ||
kind: Kind::VerdictRequest, | ||
session_id, | ||
use_cache, | ||
use_hash_lookup, | ||
} | ||
} | ||
} | ||
|
||
impl VerdictRequest for VerdictRequestFile { | ||
fn guid(&self) -> &str { | ||
&self.guid | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters