pub struct Session { /* private fields */ }Expand description
Mutable state for a render sequence. See module docs.
Implementations§
Source§impl Session
impl Session
pub fn new() -> Self
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Clear all session state. Equivalent to replacing with Session::new()
but preserves allocations. Use when starting a fully unrelated
narrative in the same session — most multi-paragraph callers want
Session::reset_for_paragraph instead so style rotation continues.
NOTE: last_temporal_anchor survives so narratives can span paragraphs.
Call Session::reset_temporal to clear the anchor explicitly when
starting a temporally-disjoint narrative in the same session.
Sourcepub fn reset_for_paragraph(&mut self)
pub fn reset_for_paragraph(&mut self)
Reset paragraph-local discourse while keeping narrative-level style
continuity. Pronoun, focus, and Centering Theory state are cleared so
anaphora cannot leak across the paragraph break, but every form of
stylistic anti-repeat — list-style rotation, template-variant history,
connective history, word-repetition scoring, and Round-Robin variant
counters — survives, along with the temporal anchor. Consecutive
paragraphs therefore rotate through |join phrasings, avoid replaying
the same template variant or connective, are penalized for repeating
recent vocabulary, and continue to support inter-paragraph temporal
references.
This is the reset crate::DocumentPlan::render uses between
paragraphs. Library consumers driving their own paragraph loop should
prefer this over Session::reset.
Sourcepub fn reset_temporal(&mut self)
pub fn reset_temporal(&mut self)
Clear the temporal anchor. Use when starting a temporally-disjoint narrative in the same session.
Sourcepub fn reset_list_cycle(&mut self)
pub fn reset_list_cycle(&mut self)
Clear the discourse list-style cycle counter so the next |join pipe
starts at the first style in the rotation. Use when starting a
stylistically-disjoint narrative in the same session without doing
a full Session::reset.
Sourcepub fn discourse_mut(&mut self) -> &mut DiscourseState
pub fn discourse_mut(&mut self) -> &mut DiscourseState
Mutable access to the underlying discourse state. Use this to call
DiscourseState::mention_entity_ranked for templates where
grammatical role matters, or to read centering diagnostics such as
DiscourseState::cb, DiscourseState::cf, and
DiscourseState::last_transition.
Sourcepub fn discourse(&self) -> &DiscourseState
pub fn discourse(&self) -> &DiscourseState
Read-only access to the underlying discourse state.
Trait Implementations§
Source§impl Clone for Session
impl Clone for Session
Source§fn clone(&self) -> Self
fn clone(&self) -> Self
Deep clone. The RoundRobin counters are cloned by reading each
atomic with Ordering::Relaxed — fine because clones are used
as snapshot/restore checkpoints around fallible renders and there
is no concurrent writer during a clone.
last_temporal_anchor is copied so snapshot/restore checkpoints
preserve the temporal state correctly.
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more