pub struct File<'a> {
pub old_path: Option<Cow<'a, Path>>,
pub path: Cow<'a, Path>,
pub file_mode: 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: 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 look for a user-provided update to the file
mode in the changes returned from File::get_selected_contents()
.
sections: Vec<Section<'a>>
The set of Section
s inside the file.
Implementations§
Source§impl File<'_>
impl File<'_>
Sourcepub fn get_selected_contents(
&self,
) -> (SelectedChanges<'_>, SelectedChanges<'_>)
pub fn get_selected_contents( &self, ) -> (SelectedChanges<'_>, SelectedChanges<'_>)
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>,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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