Skip to content

Commit b9f8114

Browse files
committed
feat: allow converting back to string
1 parent cfe44b0 commit b9f8114

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

csaf-rs/src/csaf/validation.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::collections::HashMap;
2+
use std::fmt::{Display, Formatter};
23
use std::str::FromStr;
34

45
#[derive(Debug, PartialEq, Eq, Hash, Clone, serde::Serialize)]
@@ -38,6 +39,16 @@ impl FromStr for ValidationPreset {
3839
}
3940
}
4041

42+
impl Display for ValidationPreset {
43+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
44+
match self {
45+
Self::Basic => write!(f, "basic"),
46+
Self::Extended => write!(f, "extended"),
47+
Self::Full => write!(f, "full"),
48+
}
49+
}
50+
}
51+
4152
pub trait Validate {
4253
/// Validates this object according to a validation preset
4354
fn validate_preset(&'static self, preset: ValidationPreset);
@@ -46,8 +57,7 @@ pub trait Validate {
4657
fn validate_by_test(&self, version: &str);
4758
}
4859

49-
pub type Test<VersionedDocument> =
50-
fn(&VersionedDocument) -> Result<(), ValidationError>;
60+
pub type Test<VersionedDocument> = fn(&VersionedDocument) -> Result<(), ValidationError>;
5161

5262
/// Represents something which is validatable according to the CSAF standard.
5363
/// This trait MUST be implemented by the struct that represents a CSAF document

0 commit comments

Comments
 (0)