pub struct Node {
pub name: String,
pub typ: FileType,
pub pattern: String,
pub count: usize,
pub token_count: usize,
pub file_type: String,
pub children: Vec<Node>,
}Expand description
Describes either a directory or file entry in a codebase specification.
Fields§
§name: String§typ: FileType§pattern: StringE.g. code_*.c
count: usizeNumber of files, e.g. 10.
token_count: usizeTokens per file, e.g. 20.
file_type: StringLanguage/type identifier, e.g. C or sql.
children: Vec<Node>Implementations§
Source§impl Node
impl Node
Sourcepub fn generate_structure(
&self,
resrap: &Resrap,
root: &str,
) -> Result<(), String>
pub fn generate_structure( &self, resrap: &Resrap, root: &str, ) -> Result<(), String>
Creates the directory structure and files.
Examples found in repository?
examples/codebase.rs (line 24)
15fn main() -> Result<(), String> {
16 let target = std::env::args().nth(1).unwrap_or_else(|| ".".to_string());
17
18 let mut resrap = Resrap::new();
19 templates::load(&mut resrap, templates::Lang::C)?;
20 templates::load(&mut resrap, templates::Lang::Sql)?;
21
22 // Parse the DSL (validates it) and write the files under `target`.
23 let root = resrap_rs::parse_dsl(SPEC)?;
24 root.generate_structure(&resrap, &target)?;
25 println!("Generated project in {target}");
26 Ok(())
27}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more