Refacto structures definition
This commit is contained in:
24
virtweb_backend/src/libvirt_lib_structures/mod.rs
Normal file
24
virtweb_backend/src/libvirt_lib_structures/mod.rs
Normal file
@ -0,0 +1,24 @@
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug)]
|
||||
pub struct XMLUuid(pub uuid::Uuid);
|
||||
|
||||
impl XMLUuid {
|
||||
pub fn parse_from_str(s: &str) -> anyhow::Result<Self> {
|
||||
Ok(Self(uuid::Uuid::parse_str(s)?))
|
||||
}
|
||||
|
||||
pub fn new_random() -> Self {
|
||||
Self(uuid::Uuid::new_v4())
|
||||
}
|
||||
pub fn as_string(&self) -> String {
|
||||
self.0.to_string()
|
||||
}
|
||||
|
||||
pub fn is_valid(&self) -> bool {
|
||||
log::debug!("UUID version ({}): {}", self.0, self.0.get_version_num());
|
||||
self.0.get_version_num() == 4
|
||||
}
|
||||
}
|
||||
|
||||
pub mod domain;
|
||||
pub mod network;
|
||||
pub mod nwfilter;
|
Reference in New Issue
Block a user