Skip to main content

JapaneseEngine

Struct JapaneseEngine 

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

JP engine. One per session. Cheap to construct — all data is in const tables in crate::romaji and crate::kanji.

Implementations§

Source§

impl JapaneseEngine

Source

pub fn new() -> Self

Source

pub fn handle_letter(&mut self, c: u8) -> bool

Push one ASCII letter into the buffer and re-render candidates. Returns true if the letter was accepted; rejected letters leave state unchanged so the IME controller can route the byte elsewhere (locale punct mapping, raw passthrough).

Accepted bytes:

  • a-z, A-Z (the romaji alphabet — lowercased on push)
  • - only when the buffer is non-empty — chōonpu (ー / long-vowel mark). romaji::TABLE maps - to so a buffer of "koohi-" renders as コーヒー. Empty-buffer - is rejected so a stranded hyphen still routes to the host as ASCII punctuation rather than becoming a leading with no preceding syllable. User-reported 2026-05-27: - must be typeable as JP chōonpu, otherwise long- vowel words like コーヒー are unreachable.
Source

pub fn backspace(&mut self) -> bool

Pop one byte off the buffer. Returns true if a byte was removed (i.e. buffer was non-empty), false if there was nothing to pop.

Source

pub fn escape(&mut self) -> bool

Drop the buffer entirely. Returns true if something was dropped, false if buffer was already empty.

Source

pub fn preedit(&self) -> &str

Read-only buffer view as a string (for the preedit display).

Source

pub fn is_composing(&self) -> bool

Source

pub fn candidates(&self) -> &[Candidate]

Source

pub fn commit_index(&mut self, index: usize) -> Option<String>

Commit the candidate at index. Returns the committed text and clears the buffer. None if index is out of range (state unchanged).

Trait Implementations§

Source§

impl Default for JapaneseEngine

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