[−][src]Struct gcsf::FileManager
Manages files locally and uses a DriveFacade in order to communicate with Google Drive and to ensure consistency between the local and remote state.
Fields
files: HashMap<u64, File>
Maps inodes to the corresponding files.
node_ids: HashMap<u64, NodeId>
Maps inodes to corresponding node ids that tree
uses.
drive_ids: HashMap<String, u64>
Maps Google Drive ids (i.e strings) to corresponding inodes.
df: DriveFacade
A DriveFacade
is used in order to communicate with the Google Drive API.
last_sync: SystemTime
The last timestamp when the file manager asked Google Drive for remote changes.
sync_interval: Duration
Specifies how much time is needed to pass since last_sync
for a new sync to be performed.
rename_identical_files: bool
Rename duplicate files if enabled.
skip_trash: bool
If enabled, deleting files will remove them permanently instead of moving them to Trash. Deleting trashed files always removes them permanently.
Methods
impl FileManager
[src]
pub fn with_drive_facade(
rename_identical_files: bool,
skip_trash: bool,
sync_interval: Duration,
df: DriveFacade
) -> Result<Self, Error>
[src]
rename_identical_files: bool,
skip_trash: bool,
sync_interval: Duration,
df: DriveFacade
) -> Result<Self, Error>
Creates a new FileManager with a specific sync_interval
and an injected DriveFacade
.
Also populates the manager's file tree with files contained in "My Drive" and "Trash".
pub fn sync(&mut self) -> Result<(), Error>
[src]
Tries to retrieve recent changes from the DriveFacade
and apply them locally in order to
maintain data consistency. Fails early if not enough time has passed since the last sync.
pub fn next_available_inode(&mut self) -> u64
[src]
Returns the next unused inode.
pub fn contains(&self, file_id: &FileId) -> bool
[src]
pub fn get_node_id(&self, file_id: &FileId) -> Option<NodeId>
[src]
pub fn get_drive_id(&self, id: &FileId) -> Option<String>
[src]
pub fn get_inode(&self, id: &FileId) -> Option<u64>
[src]
pub fn get_children(&self, id: &FileId) -> Option<Vec<&File>>
[src]
pub fn get_file(&self, id: &FileId) -> Option<&File>
[src]
pub fn get_mut_file(&mut self, id: &FileId) -> Option<&mut File>
[src]
pub fn create_file(
&mut self,
file: File,
parent: Option<FileId>
) -> Result<(), Error>
[src]
&mut self,
file: File,
parent: Option<FileId>
) -> Result<(), Error>
Creates a file on Drive and adds it to the local file tree.
pub fn flush(&mut self, id: &FileId) -> Result<(), Error>
[src]
Passes along the FLUSH system call to the DriveFacade
.
pub fn delete(&mut self, id: &FileId) -> Result<(), Error>
[src]
Deletes a file locally and on Drive.
pub fn move_file_to_trash(
&mut self,
id: &FileId,
also_on_drive: bool
) -> Result<(), Error>
[src]
&mut self,
id: &FileId,
also_on_drive: bool
) -> Result<(), Error>
Moves a file to the Trash directory locally and on Drive.
pub fn file_is_trashed(&mut self, id: &FileId) -> Result<bool, Error>
[src]
Whether a file is trashed on Drive.
pub fn rename(
&mut self,
id: &FileId,
new_parent: u64,
new_name: String
) -> Result<(), Error>
[src]
&mut self,
id: &FileId,
new_parent: u64,
new_name: String
) -> Result<(), Error>
Moves/renames a file locally and on Drive.
pub fn write(&mut self, id: FileId, offset: usize, data: &[u8])
[src]
Writes to a file locally and on Drive. Note: the pending write is not necessarily applied
instantly by the DriveFacade
.
Trait Implementations
Auto Trait Implementations
impl Send for FileManager
impl !Sync for FileManager
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,