actr_cli/templates/rust/
echo.rs1use crate::error::Result;
2use crate::templates::ProjectTemplate;
3use std::collections::HashMap;
4use std::path::Path;
5
6pub fn load(files: &mut HashMap<String, String>, is_service: bool) -> Result<()> {
7 let fixtures_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("fixtures");
8
9 let cargo_hbs = if is_service {
11 fixtures_root.join("rust/Cargo.service.toml.hbs")
12 } else {
13 fixtures_root.join("rust/Cargo.toml.hbs")
14 };
15 ProjectTemplate::load_file(&cargo_hbs, files, "Cargo.toml")?;
16
17 if is_service {
19 ProjectTemplate::load_file(
20 &fixtures_root.join("rust/lib.rs.service.hbs"),
21 files,
22 "src/lib.rs",
23 )?;
24 ProjectTemplate::load_file(
25 &fixtures_root.join("rust/build.rs.service.hbs"),
26 files,
27 "build.rs",
28 )?;
29 ProjectTemplate::load_file(
30 &fixtures_root.join("rust/echo_service.rs.hbs"),
31 files,
32 "src/echo_service.rs",
33 )?;
34 } else {
35 ProjectTemplate::load_file(
36 &fixtures_root.join("rust/main.rs.hbs"),
37 files,
38 "src/main.rs",
39 )?;
40 ProjectTemplate::load_file(&fixtures_root.join("rust/lib.rs.hbs"), files, "src/lib.rs")?;
41 ProjectTemplate::load_file(
42 &fixtures_root.join("rust/echo/actr.toml.hbs"),
43 files,
44 "actr.toml",
45 )?;
46 }
47 let manifest_toml_hbs = if is_service {
48 fixtures_root.join("rust/echo/manifest.toml.service.hbs")
49 } else {
50 fixtures_root.join("rust/echo/manifest.toml.hbs")
51 };
52 ProjectTemplate::load_file(&manifest_toml_hbs, files, "manifest.toml")?;
53
54 let readme_hbs = if is_service {
56 fixtures_root.join("rust/echo/README.md.service.hbs")
57 } else {
58 fixtures_root.join("rust/echo/README.md.hbs")
59 };
60 ProjectTemplate::load_file(&readme_hbs, files, "README.md")?;
61
62 ProjectTemplate::load_file(
64 &fixtures_root.join("rust/gitignore.hbs"),
65 files,
66 ".gitignore",
67 )?;
68
69 Ok(())
70}