Struct fm::fileinfo::PathContent

source ·
pub struct PathContent {
    pub path: PathBuf,
    pub content: Vec<FileInfo>,
    pub index: usize,
    pub users_cache: UsersCache,
    /* private fields */
}
Expand description

Holds the information about file in the current directory. We know about the current path, the files themselves, the selected index, the “display all files including hidden” flag and the key to sort files.

Fields§

§path: PathBuf

The current path

§content: Vec<FileInfo>

A vector of FileInfo with every file in current path

§index: usize

The index of the selected file.

§users_cache: UsersCache

Implementations§

source§

impl PathContent

source

pub fn new( path: &Path, users_cache: UsersCache, filter: &FilterKind, show_hidden: bool ) -> FmResult<Self>

Reads the paths and creates a new PathContent. Files are sorted by filename by default. Selects the first file if any.

source

pub fn change_directory( &mut self, path: &Path, filter: &FilterKind, show_hidden: bool ) -> FmResult<()>

source

pub fn path_to_str(&self) -> FmResult<&str>

Convert a path to a &str. It may fails if the path contains non valid utf-8 chars.

source

pub fn sort(&mut self)

Sort the file with current key.

source

pub fn owner_column_width(&self) -> usize

Calculates the size of the owner column.

source

pub fn group_column_width(&self) -> usize

Calculates the size of the group column.

source

pub fn select_index(&mut self, index: usize)

Select the file from a given index.

source

pub fn reset_files( &mut self, filter: &FilterKind, show_hidden: bool ) -> Result<(), FmError>

Reset the current file content. Reads and sort the content with current key. Select the first file if any.

source

pub fn selected_path_string(&self) -> Option<String>

Path of the currently selected file.

source

pub fn contains(&self, path: &Path) -> bool

True if the path starts with a subpath.

source

pub fn is_selected_dir(&self) -> FmResult<bool>

Is the selected file a directory ? It may fails if the current path is empty, aka if nothing is selected.

source

pub fn true_len(&self) -> usize

source

pub fn used_space(&self) -> String

Human readable string representation of the space used by files in current path. No recursive exploration of directory.

source

pub fn git_string(&self) -> FmResult<String>

A string representation of the git status of the path.

source

pub fn update_sort_from_char(&mut self, c: char)

Update the kind of sort from a char typed by the user.

source

pub fn unselect_current(&mut self)

Unselect the current item. Since we use a common trait to navigate the files, this method is required.

source

pub fn select_current(&mut self)

Select the current item. Since we use a common trait to navigate the files, this method is required.

source

pub fn enumerate(&mut self) -> Enumerate<Iter<'_, FileInfo>>

Returns an enumeration of the files (FileInfo) in content.

source

pub fn refresh_users( &mut self, users_cache: UsersCache, filter: &FilterKind, show_hidden: bool ) -> FmResult<()>

Refresh the existing users.

Trait Implementations§

source§

impl SelectableContent<FileInfo> for PathContent

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, selected. selected returns an optional reference to the value.

source§

fn is_empty(&self) -> bool

True if the content is empty.

source§

fn len(&self) -> usize

The size of the content.

source§

fn prev(&mut self)

Select the prev item.

source§

fn next(&mut self)

Select the next item.

source§

fn selected(&self) -> Option<&FileInfo>

Returns a reference to the selected content.

source§

fn index(&self) -> usize

Returns the index of the selected item.

source§

fn content(&self) -> &Vec<FileInfo>

A reference to the content.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for Twhere T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> UnsafeAny for Twhere T: Any,