Skip to main content

Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }

Implementations§

Source§

impl Engine

Source

pub fn new( cfg: Config, synth: Box<dyn Synthesizer>, sink: Box<dyn AudioSink>, ) -> Self

Source

pub fn is_shutdown(&self) -> bool

Source

pub fn handle(&mut self, cmd: Command)

Source

pub fn submit( &mut self, text: String, opts: SayOpts, ) -> Result<Option<u64>, String>

Submit text for synthesis, returning the queued utterance’s id on acceptance, None if accepted but not queued (muted or empty after cleanup), or the rejection reason on failure. This is the synchronous answer a caller gets back for its own submission – distinct from error/state, which describe the engine as a whole and must not be disturbed by a rejection that has nothing to do with whatever else is legitimately in flight (see the busy check below).

Returns Ok(Some(id)) if the text was queued for synthesis. Returns Ok(None) if the submission was accepted but nothing was queued (muted, or empty after cleanup). This is not an error. Returns Err(reason) if the submission was rejected (e.g. text too long).

handle(Command::Say { .. }) calls this and discards the result, so the existing command path is unchanged for callers that do not care. A D-Bus Say method or a CLI entry point should call this directly to learn whether its own submission was accepted and queued.

Source

pub fn tick(&mut self)

One unit of work: top up the sink, or advance the queue, or unload.

Source

pub fn replace_sink(&mut self, sink: Box<dyn AudioSink>)

Swap in a fresh sink after a device failure, clearing the error.

The daemon calls this when it manages to reacquire the audio device. The queue was cleared when the failure surfaced, so this returns the engine to a clean idle state rather than resuming a half-played utterance whose audio is gone.

Source

pub fn snapshot(&self) -> Snapshot

Auto Trait Implementations§

§

impl !RefUnwindSafe for Engine

§

impl !Sync for Engine

§

impl !UnwindSafe for Engine

§

impl Freeze for Engine

§

impl Send for Engine

§

impl Unpin for Engine

§

impl UnsafeUnpin for Engine

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.