Skip to main content

History

Struct History 

Source
pub struct History {
    pub entries: Vec<HistoryEntry>,
}
Expand description

The append-only event log of an issue (data-model.md §8).

Append-only is a hard guarantee of this type: the only mutating operation is History::append. There is deliberately no remove, no reorder, no trim, and no compaction — those are out of scope, but the container is shaped so a future retention policy has a seam.

Fields§

§entries: Vec<HistoryEntry>

Every line of the section, in file order, which is append order.

Held as an ordered list of entries rather than a flat Vec<HistoryEvent> so an unparseable line keeps its position and its exact text. That is what lets the section round-trip byte-stably without ever dropping or repairing a line a human hand-edited.

Implementations§

Source§

impl History

Source

pub fn new() -> Self

An empty log.

Source

pub fn append(&mut self, event: HistoryEvent)

Append one event. Never rewrites, reorders, or removes an existing line.

Source

pub fn append_now(&mut self, actor: &str, kind: HistoryEventKind, detail: &str)

Append with the current UTC timestamp.

Source

pub fn events(&self) -> Vec<&HistoryEvent>

The parsed events, in file order.

Unparseable lines are excluded here; see History::unparsed.

Source

pub fn unparsed(&self) -> Vec<&str>

Lines that could not be parsed, verbatim and in file order.

Non-empty means the section was hand-edited into a shape this parser does not accept. tix lint reports each as a history finding; nothing else treats it as an error.

Source

pub fn is_empty(&self) -> bool

Whether the section has no lines at all.

Source

pub fn len(&self) -> usize

How many lines the section holds, parsed or not.

Source

pub fn render(&self) -> String

Render the section, including its heading and the blank line after it.

An empty log renders to the empty string, so the section is omitted from the file entirely rather than written as an empty heading. An unparseable line is re-emitted exactly as it was read, in place, so a read/write cycle is byte-stable whether or not the section is clean.

Source

pub fn parse_front(body: &str) -> (Self, String)

Parse a leading ## History section, returning the log and whatever body text followed it.

Only a section at the front of the body is recognised, matching the position data-model.md §8 pins (immediately after the frontmatter). A ## History heading appearing later in the prose is left alone as ordinary body text.

The section ends at the first line that is neither blank nor a list item, so a blank line between entries does not end it — a blank line inside a list is the most ordinary thing a human or a Markdown formatter produces, and terminating there would silently demote audit entries to body prose and reorder the log. Unparseable list items are kept verbatim rather than failing the file.

Trait Implementations§

Source§

impl Clone for History

Source§

fn clone(&self) -> Self

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 History

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for History

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for History

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for History

Source§

impl PartialEq for History

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for History

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for History

Auto Trait Implementations§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.