pub struct Trash {
pub trash_folder_files: String,
pub help: String,
/* private fields */
}Expand description
Represent a view of the trash. Its content is navigable so we use a Vector to hold the content. Only files that share the same mount point as the trash folder (generally ~/.local/share/Trash) can be moved to trash. Other files are unaffected.
Fields§
§trash_folder_files: StringThe path to the trashed files
help: StringImplementations§
Source§impl Trash
impl Trash
Sourcepub fn new(binds: &Bindings) -> Result<Self>
pub fn new(binds: &Bindings) -> Result<Self>
Creates an empty view of the trash. No file is read here, we wait for the user to open the trash first.
§Errors
This function uses std::fs::create_dir_all internally and may fail
for the same reasons.
Sourcepub fn update(&mut self) -> Result<()>
pub fn update(&mut self) -> Result<()>
Parse the info files into a new instance. Only the file we can parse are read.
§Errors
This function may fail if the trash_folder_info can’t be parsed correctly.
If any file is listed in trash_folder_info but doesn’t exist.
Sourcepub fn trash(&mut self, origin: &Path) -> Result<()>
pub fn trash(&mut self, origin: &Path) -> Result<()>
Move a file to the trash folder and create a new trash info file.
Add a new TrashInfo to the content.
§Errors
This function may fail if the origin path is a relative path. We have no way to know where the file is exactly located.
It may also fail if the trash folder can’t be located, we wouldn’t be able to create a new path for the file.
Sourcepub fn empty_trash(&mut self) -> Result<()>
pub fn empty_trash(&mut self) -> Result<()>
Empty the trash, removing all the files and the trashinfo. This action requires a confirmation. Watchout, it may delete files that weren’t parsed.
§Errors
This method may fail if the trashfolder was moved or deleted or simply doesn’t exist.
This method uses std::fs::remove_dir internally, which may fail.
See std::fs::remove_file and std::fs::remove_dir.
remove_dir_all will fail if remove_dir or remove_file fail on any constituent paths, including the root path.
Sourcepub fn restore(&mut self) -> Result<()>
pub fn restore(&mut self) -> Result<()>
Restores a file from the trash to its previous directory. If the parent (or ancestor) folder were deleted, it is recreated.
§Errors
Will return an error if the file isn’t trashed properly :
- missing .trashinfo
- missing file itself
It may also fail if the file can’t be restored : For example, if the original path of the file is now in a directory where the user has no permission to write.
Sourcepub fn delete_permanently(&mut self) -> Result<()>
pub fn delete_permanently(&mut self) -> Result<()>
Deletes a file permanently from the trash.
§Errors
Will return an error if the selected file isn’t trashed properly:
- missing .trashinfo
- missing file itself.
Trait Implementations§
Source§impl Selectable for Trash
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: is_empty, len, next, prev, set_index and selected_is_last.
impl Selectable for Trash
Implement a selectable content for this struct.
This trait allows to navigate through a vector of element content_type.
It implements: is_empty, len, next, prev, set_index and selected_is_last.
Auto Trait Implementations§
impl Freeze for Trash
impl RefUnwindSafe for Trash
impl Send for Trash
impl Sync for Trash
impl Unpin for Trash
impl UnwindSafe for Trash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more