Struct scm_record::File
source · pub struct File<'a> {
pub old_path: Option<Cow<'a, Path>>,
pub path: Cow<'a, Path>,
pub file_mode: Option<FileMode>,
pub sections: Vec<Section<'a>>,
}
Expand description
The state of a file to be recorded.
Fields§
§old_path: Option<Cow<'a, Path>>
The path to the previous version of the file, for display purposes. This should be set if the file was renamed or copied from another file.
path: Cow<'a, Path>
The path to the current version of the file, for display purposes.
file_mode: Option<FileMode>
The Unix file mode of the file (before any changes), if available. This may be rendered by the UI.
This value is not directly modified by the UI; instead, construct a
Section::FileMode
and use the [FileState::get_file_mode
] function
to read a user-provided updated to the file mode function to read a
user-provided updated to the file mode.
sections: Vec<Section<'a>>
The set of Section
s inside the file.
Implementations§
source§impl File<'_>
impl File<'_>
sourcepub fn get_file_mode(&self) -> Option<FileMode>
pub fn get_file_mode(&self) -> Option<FileMode>
Get the new Unix file mode. If the user selected a
Section::FileMode
, then returns that file mode. Otherwise, returns
the file_mode
value that this [FileState
] was constructed with.
sourcepub fn get_selected_contents(
&self
) -> (SelectedContents<'_>, SelectedContents<'_>)
pub fn get_selected_contents( &self ) -> (SelectedContents<'_>, SelectedContents<'_>)
Calculate the (selected, unselected)
contents of the file. For
example, the first value would be suitable for staging or committing,
and the second value would be suitable for potentially recording again.
sourcepub fn tristate(&self) -> Tristate
pub fn tristate(&self) -> Tristate
Get the tristate value of the file. If there are no sections in this
file, returns Tristate::False
.
sourcepub fn set_checked(&mut self, checked: bool)
pub fn set_checked(&mut self, checked: bool)
Set the selection of all sections and lines in this file.
sourcepub fn toggle_all(&mut self)
pub fn toggle_all(&mut self)
Toggle the selection of all sections in this file.
Trait Implementations§
source§impl<'de, 'a> Deserialize<'de> for File<'a>
impl<'de, 'a> Deserialize<'de> for File<'a>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<'a> PartialEq for File<'a>
impl<'a> PartialEq for File<'a>
impl<'a> Eq for File<'a>
impl<'a> StructuralPartialEq for File<'a>
Auto Trait Implementations§
impl<'a> Freeze for File<'a>
impl<'a> RefUnwindSafe for File<'a>
impl<'a> Send for File<'a>
impl<'a> Sync for File<'a>
impl<'a> Unpin for File<'a>
impl<'a> UnwindSafe for File<'a>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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