1pub use container::{app, Container};
2
3mod container;
4
5pub fn type_name<T>() -> String
6where
7 T: std::any::Any + ?Sized,
8{
9 std::any::type_name::<T>()
10 .split("::")
11 .last()
12 .expect("Cannot get type name")
13 .to_string()
14}
15
16pub fn copy(from: &std::path::Path, to: &std::path::Path) -> crate::Result<()> {
17 match std::fs::metadata(from)?.is_dir() {
18 false => {
19 std::fs::copy(from, to)?;
20 }
21 true => {
22 std::fs::create_dir_all(to)?;
23
24 for entry in std::fs::read_dir(from)? {
25 let entry = entry?;
26 let from = entry.path();
27 let to = to.join(entry.file_name());
28
29 if from.is_dir() {
30 copy(&from, &to)?;
31 } else {
32 std::fs::copy(&from, to)?;
33 }
34 }
35 }
36 };
37
38 Ok(())
39}
40
41pub fn base_path(str: &str) -> std::path::PathBuf {
42 let base_path = std::env::var("CARGO_MANIFEST_DIR")
43 .map(std::path::PathBuf::from)
44 .unwrap_or_else(|_| {
45 std::env::current_dir()
46 .expect("project directory does not exist or permissions are insufficient")
47 });
48
49 base_path.join(str)
50}