build_fs_tree/build/
impl_tree.rs

1use crate::{Build, FileSystemTree};
2use std::{
3    fs::{create_dir, write},
4    io::Error,
5    path::{Path, PathBuf},
6};
7
8impl<Name, FileContent> Build<Name, Error> for FileSystemTree<Name, FileContent>
9where
10    Name: AsRef<Path> + Ord,
11    FileContent: AsRef<[u8]>,
12{
13    type BorrowedPath = Path;
14    type OwnedPath = PathBuf;
15
16    fn join(prefix: &Self::BorrowedPath, name: &Name) -> Self::OwnedPath {
17        prefix.join(name)
18    }
19
20    fn write_file(path: &Self::BorrowedPath, content: &Self::FileContent) -> Result<(), Error> {
21        write(path, content)
22    }
23
24    fn create_dir(path: &Self::BorrowedPath) -> Result<(), Error> {
25        create_dir(path)
26    }
27}