Skip to main content

ForwardingController

Struct ForwardingController 

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

Controls the state of an active event forwarding session.

A ForwardingController is returned by EventForwarder::forward_events and provides thread-safe control over the forwarding thread.

§State

The controller maintains two atomic flags:

  • pause_flag: Controls whether captured events are currently forwarded.
    • false = forwarding is active
    • true = forwarding is paused
  • exit_flag: Signals that the forwarding session should terminate.
    • false = forwarding session is running
    • true = exit has been requested

§Behavior

Calling Self::pause temporarily disables event forwarding while keeping the underlying hooks active. Calling Self::resume enables event forwarding again.

Calling Self::exit permanently signals the forwarding session to stop. Once exit is requested, the session cannot be resumed.

Dropping the controller also signals the forwarding thread to terminate.

§Example

let controller = forwarder.forward_events()?;

controller.pause();
controller.resume();

if controller.is_forwarding() {
    println!("Forwarding is active.");
}

controller.exit()?;

Implementations§

Source§

impl ForwardingController

Source

pub fn pause(&self)

Pauses event forwarding.

The installed Windows hooks remain active while forwarding is paused, but captured events are no longer processed by EventForwarder.

Calling this method multiple times has no additional effect.

Source

pub fn resume(&self)

Resumes event forwarding.

Captured events are processed and forwarded to the configured target window again.

Calling this method while forwarding is already active has no additional effect.

Source

pub fn is_forwarding(&self) -> bool

Returns whether the forwarding session is currently active.

§Returns

Returns true when forwarding is enabled and false when forwarding is currently paused.

Source

pub fn exit(self) -> Result<(), WinErr>

Stops the event forwarding session and waits for its threads to terminate.

This method signals the forwarding thread to stop processing events and sends WM_QUIT to the dedicated hook thread. The hook thread then exits its message loop, removes the installed Windows hooks, and terminates.

The forwarding thread waits for the hook thread to finish before returning.

Once this method has been called successfully, the forwarding session cannot be resumed.

controller.exit()?;

Trait Implementations§

Source§

impl Debug for ForwardingController

Source§

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

Formats the value using the given formatter. 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 = !

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.