new: method for storage list

This commit is contained in:
qwjyh 2024-02-24 18:31:56 +09:00
parent 2f9fa08cf2
commit 71e3cad6da
3 changed files with 21 additions and 1 deletions

View file

@ -1,3 +1,4 @@
# TODO: # TODO:
- [ ] split subcommands to functions
- [ ] reorganize cmd option for storage - [ ] reorganize cmd option for storage
- [ ] use subcommand - [ ] use subcommand

View file

@ -373,6 +373,7 @@ fn main() -> Result<()> {
for (k, storage) in &storages { for (k, storage) in &storages {
println!("{}: {}", k, storage); println!("{}: {}", k, storage);
println!(" {}", storage.mount_path(&device, &storages)?.display()); println!(" {}", storage.mount_path(&device, &storages)?.display());
// println!("{}: {}", storage.shorttypename(), storage.name()); // TODO
} }
} }
StorageCommands::Bind { StorageCommands::Bind {

View file

@ -27,7 +27,25 @@ pub enum Storage {
Online(OnlineStorage), Online(OnlineStorage),
} }
impl Storage {} impl Storage {
/// Full type name like "PhysicalStorage".
pub fn typename(&self) -> &str {
match self {
Self::PhysicalStorage(_) => "PhysicalStorage",
Self::SubDirectory(_) => "SubDirectory",
Self::Online(_) => "OnlineStorage",
}
}
/// Short type name with one letter like "P".
pub fn shorttypename(&self) -> &str {
match self {
Self::PhysicalStorage(_) => "P",
Self::SubDirectory(_) => "S",
Self::Online(_) => "O",
}
}
}
impl StorageExt for Storage { impl StorageExt for Storage {
fn name(&self) -> &String { fn name(&self) -> &String {