pub struct Session { /* private fields */ }Expand description
One controller’s bounded word state; contains no native objects or callbacks. It holds at
most one word of MAX_WORD units plus its Space, the word’s receipt, and 256 UTF-16 units
of history.
Implementations§
Source§impl Session
impl Session
Sourcepub fn has_pending(&self) -> bool
pub fn has_pending(&self) -> bool
Whether a copied proposal is awaiting acknowledgement.
Sourcepub fn has_word(&self) -> bool
pub fn has_word(&self) -> bool
Whether the session holds an owned word. This is not evidence that the host still shows the mark, and it grants no native authority.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Invalidate outstanding tokens and drop all text/receipts on native lifecycle change. The session returns to Idle with no history; the keyboard and fixture selections stay.
Sourcepub fn set_fixtures(&mut self, enabled: bool) -> Result<(), Error>
pub fn set_fixtures(&mut self, enabled: bool) -> Result<(), Error>
Enable the deterministic fixture policy of Session::propose, which converts only
ghbdtn and руддщ, while idle.
§Errors
Error::Invalidated if a word is owned or a proposal awaits acknowledgement.
Sourcepub fn set_keyboard(&mut self, keyboard: Keyboard) -> Result<(), Error>
pub fn set_keyboard(&mut self, keyboard: Keyboard) -> Result<(), Error>
Select the Russian keyboard map for manual conversion and inference while idle. The
default is Keyboard::Apple, and Session::reset keeps the selection. A change
keeps the word history, which holds finished document text rather than key positions.
§Errors
Error::Invalidated if a word is owned or a proposal awaits acknowledgement.
Sourcepub fn propose(
&mut self,
event: &Event,
mode: Mode,
context: Context,
) -> Result<Plan, Error>
pub fn propose( &mut self, event: &Event, mode: Mode, context: Context, ) -> Result<Plan, Error>
Construct a proposal using only the opt-in fixture policy. Confirmed state and context remain unchanged until acknowledgement.
§Errors
Error::Invalidated if the session was invalidated or its token counter is exhausted.
Sourcepub fn propose_without_automatic(
&mut self,
event: &Event,
mode: Mode,
context: Context,
) -> Result<Plan, Error>
pub fn propose_without_automatic( &mut self, event: &Event, mode: Mode, context: Context, ) -> Result<Plan, Error>
Construct a manual-only proposal, ignoring both the model and the fixture policy.
§Errors
Error::Invalidated if the session was invalidated or its token counter is exhausted.
Sourcepub fn propose_with_inference(
&mut self,
event: &Event,
mode: Mode,
context: Context,
model: &Model<'_>,
dictionaries: Dictionaries<'_>,
policy: Policy,
) -> Result<Plan, Error>
pub fn propose_with_inference( &mut self, event: &Event, mode: Mode, context: Context, model: &Model<'_>, dictionaries: Dictionaries<'_>, policy: Policy, ) -> Result<Plan, Error>
Construct a model-backed proposal with explicit borrowed protection snapshots and policy. Only Space evaluates inference, and not after explicit intent. Context comes from this session’s verified finished words; the pending operation retains no model, vocabulary reference or native callback. See the crate-level example for a complete word.
§Errors
Error::Invalidated if the session was invalidated or its token counter is exhausted.
Sourcepub fn acknowledge(&mut self, id: u64, outcome: Outcome) -> Result<(), Error>
pub fn acknowledge(&mut self, id: u64, outcome: Outcome) -> Result<(), Error>
Confirm the latest proposal, or drop authority after refusal/unknown effect.
Outcome::Verified advances the session to the proposed state. Any other outcome
invalidates the word, its receipt and the language history, and the session refuses
proposals until Session::reset.
§Errors
Error::Stale if id is not the pending proposal; state is unchanged.