Skip to main content

NudgeState

Struct NudgeState 

Source
pub struct NudgeState {
    pub edits_since_annotation: usize,
    pub baseline: Option<Baseline>,
    pub window_intent_ids: Option<BTreeSet<String>>,
    pub reviewed: BTreeMap<String, ReviewRecord>,
    pub proof_reviewed: BTreeMap<String, bool>,
    pub throttle: BTreeMap<String, ThrottleRecord>,
}
Expand description

The whole engine state file. Every field defaults, so older / partial files deserialize cleanly.

Fields§

§edits_since_annotation: usize

Source edits since the last annotation was added (authoring-debt).

§baseline: Option<Baseline>

The edit-window baseline, if captured.

§window_intent_ids: Option<BTreeSet<String>>

The set of authored-intent ids present when the current edit window began (captured at SessionStart). Powers #7’s new-vs-backlog split: an unreviewed intent is “new this session” when its id is absent from this set, else “backlog”. None means no window was captured (no hooks / fresh checkout) — the split is then suppressed rather than guessed.

§reviewed: BTreeMap<String, ReviewRecord>

annotation id → review record.

§proof_reviewed: BTreeMap<String, bool>

proof id → reviewed.

§throttle: BTreeMap<String, ThrottleRecord>

signal id → throttle record.

Implementations§

Source§

impl NudgeState

Source

pub fn load(path: &Path) -> Self

Read the state file, tolerating absence and corruption (either yields default state). A nudge hook must never fail on bad state.

Source

pub fn save(&self, path: &Path) -> Result<()>

Atomically write the state file (tempfile in the same dir + rename).

Source

pub fn unreviewed_count<'a>( &self, current: impl IntoIterator<Item = (&'a str, &'a str, &'a str)>, ) -> usize

Count intents the user has not (currently) reviewed. An intent is unreviewed when it has no record, its record is reviewed = false, or its live hashes have drifted from the reviewed snapshot (a post-review edit re-opens it). current is (id, text_hash, body_hash) for every authored intent in the index.

Source

pub fn is_reviewed(&self, id: &str, text_hash: &str, body_hash: &str) -> bool

True iff this annotation is currently reviewed (record present, reviewed = true, and both hashes still match — no drift).

Source

pub fn mark_reviewed(&mut self, id: &str, text_hash: &str, body_hash: &str)

Mark an annotation reviewed against its current hashes (clears any prior drift).

Trait Implementations§

Source§

impl Clone for NudgeState

Source§

fn clone(&self) -> NudgeState

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 NudgeState

Source§

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

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

impl Default for NudgeState

Source§

fn default() -> NudgeState

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

impl<'de> Deserialize<'de> for NudgeState

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 PartialEq for NudgeState

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for NudgeState

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 NudgeState

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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.