CVRF: init

Signed-off-by: Jia Chao <jiac13@chinaunicom.cn>
This commit is contained in:
Jia Chao 2024-05-28 16:42:44 +08:00
parent eaeda3a3dc
commit d5ae380bb5

View File

@ -1,14 +1,101 @@
pub fn add(left: usize, right: usize) -> usize { #![cfg_attr(
left + right debug_assertions,
allow(dead_code, unused_imports, unused_variables, unused_mut)
)]
#[derive(Debug, Clone)]
struct CVRF {
// <DocumentTitle xml:lang="en">
pub documenttitle: String,
// <DocumentType>
pub documenttype: String,
// <DocumentPublisher Type="Vendor">
pub documentpublisher: Publisher,
// <DocumentTracking>
pub documenttracking: DocumentTracking,
// <DocumentNotes>
pub documentnotes: Vec<Note>,
// <DocumentReferences>
pub documentreferences: Vec<Reference>,
// <ProductTree xmlns="http://www.icasi.org/CVRF/schema/prod/1.1">
pub producttree: ProductTree,
// <Vulnerability xmlns="http://www.icasi.org/CVRF/schema/vuln/1.1" Ordinal="1">
pub vulnerability: Vulnerability,
} }
#[cfg(test)] impl CVRF {
mod tests { // 新建一个空 CVRF
use super::*; pub fn new() -> Self {
CVRF {
#[test] documenttitle: String::new(),
fn it_works() { documenttype: String::new(),
let result = add(2, 2); documentpublisher: Publisher::new(),
assert_eq!(result, 4); documenttracking: DocumentTracking::new(),
documentnotes: vec![],
documentreferences: vec![],
producttree: ProductTree::new(),
vulnerability: Vulnerability::new(),
}
}
}
#[derive(Debug, Clone)]
struct Publisher;
impl Publisher {
pub fn new() -> Self {
Publisher
}
}
#[derive(Debug, Clone)]
struct DocumentTracking;
impl DocumentTracking {
pub fn new() -> Self {
DocumentTracking
}
}
#[derive(Debug, Clone)]
struct Note;
impl Note {
pub fn new() -> Self {
Note
}
}
#[derive(Debug, Clone)]
struct Reference;
impl Reference {
pub fn new() -> Self {
Reference
}
}
#[derive(Debug, Clone)]
struct ProductTree;
impl ProductTree {
pub fn new() -> Self {
ProductTree
}
}
#[derive(Debug, Clone)]
struct Vulnerability;
impl Vulnerability {
pub fn new() -> Self {
Vulnerability
} }
} }