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 {
left + right
#![cfg_attr(
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)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
impl CVRF {
// 新建一个空 CVRF
pub fn new() -> Self {
CVRF {
documenttitle: String::new(),
documenttype: String::new(),
documentpublisher: Publisher::new(),
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
}
}