[][src]Struct gcsf::FileManager

pub struct FileManager {
    pub files: HashMap<u64, File>,
    pub node_ids: HashMap<u64, NodeId>,
    pub drive_ids: HashMap<String, u64>,
    pub df: DriveFacade,
    pub last_sync: SystemTime,
    pub sync_interval: Duration,
    pub rename_identical_files: bool,
    pub skip_trash: bool,
    // some fields omitted
}

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]

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]

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]

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]

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

impl Debug for FileManager[src]

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]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

fn get_type(&self) -> TypeId

Get the TypeId of this object.