git-bug 0.2.4

A rust library for interfacing with git-bug repositories
Documentation
// git-bug-rs - A rust library for interfacing with git-bug repositories
//
// Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
// SPDX-License-Identifier: GPL-3.0-or-later
//
// This file is part of git-bug-rs/git-gub.
//
// You should have received a copy of the License along with this program.
// If not, see <https://www.gnu.org/licenses/agpl.txt>.

//! The timeline of an [`Snapshot`][`super::Snapshot`].
//!
//! This records changes to the Snapshot over time, in a abstract way (i.e.,
//! easier to access compared to the raw operations, but not enough data to
//! actually re-construct it.)

use crate::replica::entity::{Entity, operation::Operation};

pub mod history_step;

/// A representation of the history of an issue.
///
/// This tracks all the changes, and can be used to access the final values of
/// an issue.
pub trait Timeline<E: Entity> {
    /// Construct a new, empty [`Timeline`].
    #[must_use]
    fn new() -> Self;

    /// Construct an [`Timeline`] from a root operation.
    fn from_root_operation(operation: &Operation<E>) -> Self;

    /// Add an operation to this timeline.
    fn add(&mut self, operation: &Operation<E>);

    /// Return the complete history.
    ///
    /// This is useful, if you need to know the chronological relationship from
    /// two destict data values (i.e., Label and Status change).
    #[must_use]
    fn history(&self) -> &[E::HistoryStep];
}