2023-08-29 02:11:47 +09:00
|
|
|
//! Manipulates storages.
|
|
|
|
|
|
|
|
use clap::ValueEnum;
|
|
|
|
use physical_drive_partition::PhysicalDrivePartition;
|
|
|
|
use serde::{Deserialize, Serialize};
|
2023-08-29 04:22:04 +09:00
|
|
|
use std::fmt;
|
2023-08-29 02:11:47 +09:00
|
|
|
|
|
|
|
/// YAML file to store known storages..
|
|
|
|
pub const STORAGESFILE: &str = "storages.yml";
|
|
|
|
|
|
|
|
#[derive(ValueEnum, Clone, Copy, Debug)]
|
|
|
|
pub enum StorageType {
|
|
|
|
Physical,
|
|
|
|
// Online,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// All storage types.
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
pub enum Storage {
|
|
|
|
PhysicalStorage(PhysicalDrivePartition),
|
|
|
|
// /// Online storage provided by others.
|
|
|
|
// OnlineStorage {
|
|
|
|
// name: String,
|
|
|
|
// provider: String,
|
|
|
|
// capacity: u8,
|
|
|
|
// },
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Storage {
|
|
|
|
pub fn name(&self) -> &String {
|
|
|
|
match self {
|
|
|
|
Self::PhysicalStorage(s) => s.name(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 04:22:04 +09:00
|
|
|
impl fmt::Display for Storage {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
match self {
|
|
|
|
Self::PhysicalStorage(s) => s.fmt(f),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 02:11:47 +09:00
|
|
|
/// Trait to manipulate all `Storage`s (Enums).
|
|
|
|
pub trait StorageExt {
|
|
|
|
fn name(&self) -> &String;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub mod physical_drive_partition;
|