git_bug/replica/entity/snapshot/timeline/
mod.rs

1// git-bug-rs - A rust library for interfacing with git-bug repositories
2//
3// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
4// SPDX-License-Identifier: GPL-3.0-or-later
5//
6// This file is part of git-bug-rs/git-gub.
7//
8// You should have received a copy of the License along with this program.
9// If not, see <https://www.gnu.org/licenses/agpl.txt>.
10
11//! The timeline of an [`Snapshot`][`super::Snapshot`].
12//!
13//! This records changes to the Snapshot over time, in a abstract way (i.e.,
14//! easier to access compared to the raw operations, but not enough data to
15//! actually re-construct it.)
16
17use crate::replica::entity::{Entity, operation::Operation};
18
19pub mod history_step;
20
21/// A representation of the history of an issue.
22///
23/// This tracks all the changes, and can be used to access the final values of
24/// an issue.
25pub trait Timeline<E: Entity> {
26    /// Construct a new, empty [`Timeline`].
27    #[must_use]
28    fn new() -> Self;
29
30    /// Construct an [`Timeline`] from a root operation.
31    fn from_root_operation(operation: &Operation<E>) -> Self;
32
33    /// Add an operation to this timeline.
34    fn add(&mut self, operation: &Operation<E>);
35
36    /// Return the complete history.
37    ///
38    /// This is useful, if you need to know the chronological relationship from
39    /// two destict data values (i.e., Label and Status change).
40    #[must_use]
41    fn history(&self) -> &[E::HistoryStep];
42}