mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 20:55:50 +00:00
* Moved commands into their own folder to reduce `bin.rs`'s size * Moved all of the VFS-related functionality into its own folder * Documented a lot of functions, including a few very obscure ones
32 lines
799 B
Rust
32 lines
799 B
Rust
use std::collections::HashMap;
|
|
|
|
/// A VfsItem represents either a file or directory as it came from the filesystem.
|
|
///
|
|
/// The interface here is intentionally simplified to make it easier to traverse
|
|
/// files that have been read into memory.
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
#[serde(rename_all = "camelCase", tag = "type")]
|
|
pub enum VfsItem {
|
|
File {
|
|
route: Vec<String>,
|
|
contents: String,
|
|
},
|
|
Dir {
|
|
route: Vec<String>,
|
|
children: HashMap<String, VfsItem>,
|
|
},
|
|
}
|
|
|
|
impl VfsItem {
|
|
pub fn name(&self) -> &String {
|
|
self.route().last().unwrap()
|
|
}
|
|
|
|
pub fn route(&self) -> &[String] {
|
|
match self {
|
|
&VfsItem::File { ref route, .. } => route,
|
|
&VfsItem::Dir { ref route, .. } => route,
|
|
}
|
|
}
|
|
}
|