Expand description
Traits and error types for interacting with files and directories
The purpose of this module is to specify what consumers of this library must
implement in order for the filesystem calls in git-async to work.
The FileSystem trait is a wrapper trait which has associated types for
objects which implement File and Directory. The correct way to
implement this is to use a zero-sized struct for the parent, and real
objects for File and Directory. This structure is to avoid generic
proliferation as much as possible.
For example:
struct MyFile {
/* path, handle, etc. */
}
impl File for MyFile {
/* methods */
}
struct MyDirectory {
/* path, handle, etc. */
}
impl Directory<MyFile> for MyDirectory {
/* methods */
}
struct MyFS;
impl FileSystem for MyFS {
type Directory = MyDirectory;
type File = MyFile;
}The simplest way of implementing these would be to use std::fs, but this
nullifies the async capabilities of this crate. If you are using Tokio for
example, you should use primitives from
tokio::fs. If you are using
git-async in a browser, you may want to use the web filesystem
API.
Structs§
Enums§
- DirEntry
- Represents a directory entry
- File
System Error - An error encountered when doing file or directory operations.
Traits§
- Directory
- A trait for directories and their operations
- File
- A trait for reading files
- File
System - A wrapper trait encapsulating filesystem objects