pub struct GitStatsState { /* private fields */ }Expand description
Git stats state for markdown source files.
Tracks additions, modifications, and deletions from git diff.
Implementations§
Source§impl GitStatsState
impl GitStatsState
Source§impl GitStatsState
impl GitStatsState
Source§impl GitStatsState
impl GitStatsState
Source§impl GitStatsState
impl GitStatsState
Sourcepub fn update(&mut self, source_path: Option<&Path>) -> bool
pub fn update(&mut self, source_path: Option<&Path>) -> bool
Update git stats if show is enabled and enough time has passed.
This method should be called periodically (e.g., in the render loop). It only computes stats every 2 seconds to avoid excessive git calls.
§Arguments
source_path- The path to the source file, if any.
§Returns
true if stats were updated, false otherwise.
Source§impl GitStatsState
impl GitStatsState
Sourcepub fn update_if_changed(
&mut self,
source_path: Option<&Path>,
watcher: &mut GitWatcher,
) -> bool
pub fn update_if_changed( &mut self, source_path: Option<&Path>, watcher: &mut GitWatcher, ) -> bool
Update git stats using a GitWatcher for change detection.
This method only computes git stats when the watcher detects that the git repository state has changed, making it more efficient than time-based polling.
§Arguments
source_path- The path to the source file, if any.watcher- A mutable reference to the GitWatcher.
§Returns
true if stats were updated, false otherwise.
§Example
use ratatui_toolkit::markdown_widget::state::git_stats_state::GitStatsState;
use ratatui_toolkit::services::git_watcher::GitWatcher;
use std::path::Path;
let mut git_stats = GitStatsState::new();
git_stats.set_show(true);
let mut watcher = GitWatcher::new().unwrap();
watcher.watch(Path::new(".")).unwrap();
// In your event loop:
if git_stats.update_if_changed(Some(Path::new("README.md")), &mut watcher) {
println!("Git stats updated!");
}Sourcepub fn force_update(&mut self, source_path: Option<&Path>)
pub fn force_update(&mut self, source_path: Option<&Path>)
Force update git stats immediately.
This bypasses both time-based and watcher-based checks and immediately computes git stats.
§Arguments
source_path- The path to the source file, if any.
Trait Implementations§
Source§impl Clone for GitStatsState
impl Clone for GitStatsState
Source§fn clone(&self) -> GitStatsState
fn clone(&self) -> GitStatsState
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GitStatsState
impl Debug for GitStatsState
Auto Trait Implementations§
impl Freeze for GitStatsState
impl RefUnwindSafe for GitStatsState
impl Send for GitStatsState
impl Sync for GitStatsState
impl Unpin for GitStatsState
impl UnwindSafe for GitStatsState
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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>
Converts
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>
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().