Trait nebari::io::FileManager
source · [−]pub trait FileManager: ManagedFileOpener<Self::File> + Default + Clone + Debug + Send + Sync + 'static {
type File: ManagedFile<Manager = Self>;
type FileHandle: OpenableFile<Self::File> + OperableFile<Self::File>;
fn read(&self, path: impl AsRef<Path>) -> Result<Self::FileHandle, Error>;
fn append(&self, path: impl AsRef<Path>) -> Result<Self::FileHandle, Error>;
fn file_length(&self, path: impl AsRef<Path>) -> Result<u64, Error>;
fn exists(&self, path: impl AsRef<Path>) -> Result<bool, Error>;
fn close_handles<F: FnOnce(u64)>(
&self,
path: impl AsRef<Path>,
publish_callback: F
);
fn delete(&self, path: impl AsRef<Path>) -> Result<bool, Error>;
fn delete_directory(&self, path: impl AsRef<Path>) -> Result<(), Error>;
}
Expand description
A manager that is responsible for controlling write access to a file.
Associated Types
type File: ManagedFile<Manager = Self>
type File: ManagedFile<Manager = Self>
The type of file managed by this manager.
type FileHandle: OpenableFile<Self::File> + OperableFile<Self::File>
type FileHandle: OpenableFile<Self::File> + OperableFile<Self::File>
A file handle type, which can have operations executed against it.
Required methods
Returns a file handle that can be used for reading operations.
Returns a file handle that can be used to read and write.
Returns the length of the file.
Closes all open handles for path
, and calls publish_callback
before
unlocking any locks aquired during the operation.