Skip to main content

Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

Mutable state for a render sequence. See module docs.

Implementations§

Source§

impl Session

Source

pub fn new() -> Self

Source

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.

Source

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.

Source

pub fn reset_temporal(&mut self)

Clear the temporal anchor. Use when starting a temporally-disjoint narrative in the same session.

Source

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.

Source

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.

Source

pub fn discourse(&self) -> &DiscourseState

Read-only access to the underlying discourse state.

Trait Implementations§

Source§

impl Clone for Session

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for Session

Source§

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

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

impl Default for Session

Source§

fn default() -> Self

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

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