Crate tfc

Source
Expand description

The core of TFC is the Context. To start generating fake input events, you’ll need to create a context. The context by itself is basically useless unless you import the traits. The trait methods return an Error if something goes wrong. Bringing these three things together, we end up with this.

use std::{thread, time::Duration};
use tfc::{Context, Error, traits::*};

fn main() -> Result<(), Error> {
    let mut ctx = Context::new()?;
    // For OS-specific reasons, it's necessary to wait a moment after
    // creating the context before generating events.
    thread::sleep(Duration::from_millis(10));
    ctx.unicode_string("Hello world!")
}

In addition to the context and its traits, there is also Command. This represents an action to perform on the context. It’s possible to serialize a command, send it over a network, deserialize it and then execute it. In fact, this is what TFC-server does.

Re-exports§

pub use traits::*;

Modules§

traits
A collection of traits that Context implements.

Structs§

Context
The main context used for generating events (Linux-Wayland).
EnumIterator
An iterator for the variants of an Enum.

Enums§

Command
A future invocation of a method on a Context.
CommandBytesError
Error enum returned by Command::from_bytes.
CommandCode
The discriminant of Command (useful for serialization).
GenericError
Error enum returned by the traits.
Key
A keyboard key used by the KeyboardContext trait.
MouseButton
A mouse button used by the MouseContext trait.

Traits§

Enum
An enum with limited reflection capabilities.

Type Aliases§

Error
Convenience type alias for GenericError.