gitignore_template_generator/fs/api.rs
1use std::io::Error;
2
3pub use crate::fs::impls::DirectoryHandler;
4
5/// File system handler trait to handle common file system operations.
6pub trait FileSystemHandler {
7 /// Fetches the file content.
8 ///
9 /// File location is not taken into consideration here. It is up to
10 /// the struct implementing this trait to take that decision.
11 ///
12 /// # Arguments
13 ///
14 /// * `file_name` - The name of the file to be fetched
15 ///
16 /// # Returns
17 ///
18 /// A result containing the fetched file content, or a
19 /// [`std::io::Error`] on error (e.g. file system failure, insufficient
20 /// privilege...).
21 fn fetch_content(&self, file_name: &str) -> Result<String, Error>;
22
23 /// List files.
24 ///
25 /// File location is not taken into consideration here. It is up to
26 /// the struct implementing this trait to take that decision.
27 ///
28 /// # Returns
29 ///
30 /// A result containing the list of files, or a
31 /// [`std::io::Error`] on error (e.g. file system failure, insufficient
32 /// privilege...).
33 fn list_files(&self) -> Result<Vec<String>, Error>;
34}