From 8a8b638bfb236a0fd8c6e70cdca670df46ebe4b9 Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Sun, 18 Feb 2024 11:33:34 +0100 Subject: [PATCH] move into submodule --- gdriver-common/src/drive_structure.rs | 25 +--------------- .../src/drive_structure/drive_id.rs | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 gdriver-common/src/drive_structure/drive_id.rs diff --git a/gdriver-common/src/drive_structure.rs b/gdriver-common/src/drive_structure.rs index 136098c..31aafdb 100644 --- a/gdriver-common/src/drive_structure.rs +++ b/gdriver-common/src/drive_structure.rs @@ -1,24 +1 @@ -pub mod drive_id { - use lazy_static::lazy_static; - use serde::{Deserialize, Serialize}; - - lazy_static! { - pub static ref ROOT_ID: DriveId = DriveId(String::from("root")); - } - #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] - pub struct DriveId(pub String); - - impl From for DriveId - where - T: Into, - { - fn from(s: T) -> Self { - DriveId(s.into()) - } - } - impl AsRef for DriveId { - fn as_ref(&self) -> &str { - &self.0 - } - } -} +pub mod drive_id; diff --git a/gdriver-common/src/drive_structure/drive_id.rs b/gdriver-common/src/drive_structure/drive_id.rs new file mode 100644 index 0000000..20b3a91 --- /dev/null +++ b/gdriver-common/src/drive_structure/drive_id.rs @@ -0,0 +1,29 @@ +use lazy_static::lazy_static; +use serde::{Deserialize, Serialize}; +use std::fmt::{Display, Formatter}; + +lazy_static! { + pub static ref ROOT_ID: DriveId = DriveId(String::from("root")); +} +#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct DriveId(pub String); + +impl From for DriveId +where + T: Into, +{ + fn from(s: T) -> Self { + DriveId(s.into()) + } +} + +impl AsRef for DriveId { + fn as_ref(&self) -> &str { + &self.0 + } +} +impl Display for DriveId { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "[{}]", self.0) + } +}