Struct fm::fileinfo::FileInfo

source ·
pub struct FileInfo {
Show 13 fields pub path: PathBuf, pub filename: String, pub size: u64, pub file_size: String, pub dir_symbol: char, pub permissions: String, pub owner: String, pub group: String, pub system_time: String, pub is_selected: bool, pub file_kind: FileKind, pub extension: String, pub kind_format: String,
}
Expand description

Infos about a file We read and keep tracks every displayable information about a file. Like in exa we don’t display the group.

Fields§

§path: PathBuf

Full path of the file

§filename: String

Filename

§size: u64

size (nb of bytes) of the file

§file_size: String

File size as a String, already human formated.

§dir_symbol: char

First symbol displaying the kind of file.

§permissions: String

Str formatted permissions like rwxr..rw.

§owner: String

Owner name of the file.

§group: String

Group name of the file.

§system_time: String

System time of last modification

§is_selected: bool

Is this file currently selected ?

§file_kind: FileKind

What kind of file is this ?

§extension: String

Extension of the file. "" for a directory.

§kind_format: String

A formated filename where the “kind” of file (directory, char device, block devive, fifo, socket, normal) is prepend to the name, allowing a “sort by kind” method.

Implementations§

source§

impl FileInfo

source

pub fn new(direntry: &DirEntry, users_cache: &UsersCache) -> FmResult<FileInfo>

Reads every information about a file from its metadata and returs a new FileInfo object if we can create one.

source

pub fn from_path_with_name( path: &Path, filename: &str, users_cache: &UsersCache ) -> FmResult<Self>

Creates a fileinfo from a path and a filename. The filename is used when we create the fileinfo for “.” and “..” in every folder.

source

pub fn from_path(path: &Path, users_cache: &UsersCache) -> FmResult<Self>

source

pub fn format( &self, owner_col_width: usize, group_col_width: usize ) -> FmResult<String>

Format the file line. Since files can have different owners in the same directory, we need to know the maximum size of owner column for formatting purpose.

source

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

source

pub fn select(&mut self)

Select the file.

source

pub fn unselect(&mut self)

Unselect the file.

source

pub fn is_hidden(&self) -> bool

source

pub fn is_dir(&self) -> bool

Trait Implementations§

source§

impl Clone for FileInfo

source§

fn clone(&self) -> FileInfo

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FileInfo

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
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
§

impl<T> CloneAny for Twhere T: Any + Clone + Send + Sync,

§

fn clone_any(&self) -> Box<dyn CloneAny + 'static, Global>

§

fn clone_any_send(&self) -> Box<dyn CloneAny + Send + 'static, Global>

§

fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync + 'static, Global>

§

fn clone_any_send_sync( &self ) -> Box<dyn CloneAny + Sync + Send + 'static, Global>

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> DebugAny for Twhere T: Any + Debug,

§

impl<T> UnsafeAny for Twhere T: Any,