-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f81cb4b
commit c6dcc3f
Showing
9 changed files
with
169 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use super::{cve_description::CveDescription, cve_id::CveId, cve_publication_date::CvePublicationDate, cve_state::CveState}; | ||
|
||
|
||
pub struct Cve { | ||
pub id: CveId, | ||
pub state: CveState, | ||
pub date_published: CvePublicationDate, | ||
|
||
pub description: CveDescription, | ||
} |
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,37 @@ | ||
use crate::shared::domain::errors::DomainError; | ||
use std::hash::{Hash, Hasher}; | ||
|
||
#[derive(Debug)] | ||
pub struct CveDescription { | ||
value: String, | ||
} | ||
|
||
impl CveDescription { | ||
pub fn new(value: String) -> Result<Self, DomainError> { | ||
Ok(Self { value }) | ||
} | ||
|
||
pub fn value(&self) -> String { | ||
self.value.clone() | ||
} | ||
} | ||
|
||
impl Clone for CveDescription { | ||
fn clone(&self) -> Self { | ||
Self::new(self.value.clone()).unwrap() | ||
} | ||
} | ||
|
||
impl PartialEq for CveDescription { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.value() == other.value() | ||
} | ||
} | ||
|
||
impl Eq for CveDescription {} | ||
|
||
impl Hash for CveDescription { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.value.hash(state); | ||
} | ||
} |
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,40 @@ | ||
use crate::shared::domain::errors::DomainError; | ||
use std::hash::{Hash, Hasher}; | ||
|
||
#[derive(Debug)] | ||
pub struct CveId { | ||
value: String, | ||
} | ||
|
||
impl CveId { | ||
pub fn new(id: String) -> Result<Self, DomainError> { | ||
if id.contains(" ") { | ||
return Err(DomainError::ValueObjectError { value: "CVE id must not contain blank spaces".to_string() }) | ||
} | ||
Ok(Self { value: id }) | ||
} | ||
|
||
pub fn value(&self) -> String { | ||
self.value.clone() | ||
} | ||
} | ||
|
||
impl Clone for CveId { | ||
fn clone(&self) -> Self { | ||
Self::new(self.value.clone()).unwrap() | ||
} | ||
} | ||
|
||
impl PartialEq for CveId { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.value() == other.value() | ||
} | ||
} | ||
|
||
impl Eq for CveId {} | ||
|
||
impl Hash for CveId { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.value.hash(state); | ||
} | ||
} |
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,37 @@ | ||
use crate::shared::domain::errors::DomainError; | ||
use std::hash::{Hash, Hasher}; | ||
|
||
#[derive(Debug)] | ||
pub struct CvePublicationDate { | ||
value: String, | ||
} | ||
|
||
impl CvePublicationDate { | ||
pub fn new(value: String) -> Result<Self, DomainError> { | ||
Ok(Self { value }) | ||
} | ||
|
||
pub fn value(&self) -> String { | ||
self.value.clone() | ||
} | ||
} | ||
|
||
impl Clone for CvePublicationDate { | ||
fn clone(&self) -> Self { | ||
Self::new(self.value.clone()).unwrap() | ||
} | ||
} | ||
|
||
impl PartialEq for CvePublicationDate { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.value() == other.value() | ||
} | ||
} | ||
|
||
impl Eq for CvePublicationDate {} | ||
|
||
impl Hash for CvePublicationDate { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.value.hash(state); | ||
} | ||
} |
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,37 @@ | ||
use crate::shared::domain::errors::DomainError; | ||
use std::hash::{Hash, Hasher}; | ||
|
||
#[derive(Debug)] | ||
pub struct CveState { | ||
value: String, | ||
} | ||
|
||
impl CveState { | ||
pub fn new(value: String) -> Result<Self, DomainError> { | ||
Ok(Self { value }) | ||
} | ||
|
||
pub fn value(&self) -> String { | ||
self.value.clone() | ||
} | ||
} | ||
|
||
impl Clone for CveState { | ||
fn clone(&self) -> Self { | ||
Self::new(self.value.clone()).unwrap() | ||
} | ||
} | ||
|
||
impl PartialEq for CveState { | ||
fn eq(&self, other: &Self) -> bool { | ||
self.value() == other.value() | ||
} | ||
} | ||
|
||
impl Eq for CveState {} | ||
|
||
impl Hash for CveState { | ||
fn hash<H: Hasher>(&self, state: &mut H) { | ||
self.value.hash(state); | ||
} | ||
} |
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,5 @@ | ||
pub mod cve; | ||
pub mod cve_description; | ||
pub mod cve_id; | ||
pub mod cve_state; | ||
pub mod cve_publication_date; |
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 @@ | ||
pub mod entities; |
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 @@ | ||
pub mod domain; |
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 @@ | ||
pub mod cves; |