pub struct BroadcastContext { /* private fields */ }Expand description
A recognition context paired with a one or more subscribers that can be awaited for recognition.
Implementations§
Source§impl BroadcastContext
impl BroadcastContext
Sourcepub fn new(
recognizer: &Recognizer,
buffer: usize,
) -> Result<(Self, BroadcastSubscriber)>
pub fn new( recognizer: &Recognizer, buffer: usize, ) -> Result<(Self, BroadcastSubscriber)>
Creates a new recognition context for the given recognizer, configured to buffer up to the
given number of recognized phrases. If a new phrase is recognized while one or more
subscribers haven’t received it, it will be dropped and those subscribers will yield a
BroadcastResult::Lagged on next await.
Sourcepub fn subscribe(&self) -> BroadcastSubscriber
pub fn subscribe(&self) -> BroadcastSubscriber
Creates a subscriber for this context.
Methods from Deref<Target = Context>§
Sourcepub fn set_enabled(&self, enabled: bool) -> Result<()>
pub fn set_enabled(&self, enabled: bool) -> Result<()>
Enables or disables the recognition of rules from all grammars loaded into this context.
Sourcepub fn grammar_builder(&self) -> GrammarBuilder<'_>
pub fn grammar_builder(&self) -> GrammarBuilder<'_>
Creates a GrammarBuilder that will construct and load a grammar into this context.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BroadcastContext
impl RefUnwindSafe for BroadcastContext
impl Send for BroadcastContext
impl Sync for BroadcastContext
impl Unpin for BroadcastContext
impl UnwindSafe for BroadcastContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more