mirror of
https://github.com/OMGeeky/gdriver2.git
synced 2026-02-23 15:38:32 +01:00
move into submodule
This commit is contained in:
@@ -1,24 +1 @@
|
|||||||
pub mod drive_id {
|
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<T> From<T> for DriveId
|
|
||||||
where
|
|
||||||
T: Into<String>,
|
|
||||||
{
|
|
||||||
fn from(s: T) -> Self {
|
|
||||||
DriveId(s.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AsRef<str> for DriveId {
|
|
||||||
fn as_ref(&self) -> &str {
|
|
||||||
&self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
29
gdriver-common/src/drive_structure/drive_id.rs
Normal file
29
gdriver-common/src/drive_structure/drive_id.rs
Normal file
@@ -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<T> From<T> for DriveId
|
||||||
|
where
|
||||||
|
T: Into<String>,
|
||||||
|
{
|
||||||
|
fn from(s: T) -> Self {
|
||||||
|
DriveId(s.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AsRef<str> 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user