Skip to main content

Trend

Struct Trend 

Source
pub struct Trend { /* private fields */ }
Available on crate feature vcs-git only.
Expand description

The change-history metrics of a set of files sampled at several points in time (issue #333).

Each file maps to a vector aligned 1:1 with as_of_points: element i is Some(stats) when the file existed and was tracked at point i, or None when it did not exist yet (or was untracked / binary) at that point.

§Rename limitation

Each snapshot keys files by their path at that snapshot’s tip, with renames followed only within that snapshot’s walk. A file renamed between two sampled points therefore appears as two separate path series (its old name, then its new name), not one continuous series. Cross-snapshot rename stitching is deferred; document this for consumers reading the series.

Implementations§

Source§

impl Trend

Source

pub fn from_snapshots( as_of_points: Vec<i64>, per_point: Vec<HashMap<PathBuf, Stats>>, long_window_days: u32, recent_window_days: u32, truncated_shallow_clone: bool, ) -> Self

Assemble a Trend from one HistoryIndex per time point.

as_of_points are the sampled timestamps (oldest-first). per_point is the matching per-file Stats map for each point, in the same order; a point that resolved to no commit (the repository did not exist yet) contributes an empty map, leaving every file None there. The two slices must be the same length — a backend invariant, so a mismatch is a programming error rather than a user-facing one.

Source

pub fn as_of_points(&self) -> &[i64]

The sampled timestamps, oldest-first, aligned 1:1 with each file’s point vector.

Source

pub fn iter(&self) -> impl Iterator<Item = (&PathBuf, &[Option<Stats>])>

Iterate (repo-relative path, per-point stats) pairs. Each inner slice is aligned with as_of_points; elements are None where the file did not exist.

Source

pub fn len(&self) -> usize

Number of files tracked across the whole trend (the union over all points).

Source

pub fn is_empty(&self) -> bool

Whether the trend tracked no files at any point.

Source

pub fn long_window_days(&self) -> u32

Long window length, in days (constant across all points).

Source

pub fn recent_window_days(&self) -> u32

Recent window length, in days (constant across all points).

Source

pub fn truncated_shallow_clone(&self) -> bool

true when any sampled snapshot came from a shallow clone, so the per-point counts are lower bounds.

Source

pub fn deltas(&self, top: usize) -> TrendDeltas

The most-improved and most-regressed files by change in risk_score between each file’s earliest and latest present points.

A file is only eligible when it is present at two or more points (otherwise there is no direction to report). delta = last_risk - first_risk: negative means risk fell (improved), positive means it rose (regressed). top truncates each list (0 keeps all). Ties break on the file path so the output is deterministic.

Trait Implementations§

Source§

impl Clone for Trend

Source§

fn clone(&self) -> Trend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Trend

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Trend

§

impl RefUnwindSafe for Trend

§

impl Send for Trend

§

impl Sync for Trend

§

impl Unpin for Trend

§

impl UnsafeUnpin for Trend

§

impl UnwindSafe for Trend

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.