Enum tfc::Command[][src]

pub enum Command {
    KeyDown(Key),
    KeyUp(Key),
    KeyClick(Key),
    MouseMoveRel(i32i32),
    MouseMoveAbs(i32i32),
    MouseScroll(i32i32),
    MouseDown(MouseButton),
    MouseUp(MouseButton),
    MouseClick(MouseButton),
    Delay(u32),
}

A future invocation of a method on a Context.

Commands can be executed by calling execute. Each variant corresponds to a method on one of the traits.

Variants

KeyDown(Key)

Corresponds to key_down

KeyUp(Key)

Corresponds to key_up

KeyClick(Key)

Corresponds to key_click

MouseMoveRel(i32i32)

Corresponds to mouse_move_rel

MouseMoveAbs(i32i32)

Corresponds to mouse_move_abs

MouseScroll(i32i32)

Corresponds to mouse_scroll

MouseDown(MouseButton)

Corresponds to mouse_down

MouseUp(MouseButton)

Corresponds to mouse_up

MouseClick(MouseButton)

Corresponds to mouse_click

Delay(u32)

Creates a delay for a number of milliseconds

Implementations

impl Command[src]

pub fn from_bytes(buf: &[u8]) -> Result<(Command, usize), CommandBytesError>[src]

Construct a Command from a sequence of bytes.

The first byte in the buffer must be a CommandCode. This identifies the command and its arguments. Following the command identifier is a sequence of bytes that encode the arguments of the command. Key and MouseButton are single bytes. For integer arguments (used for moving the mouse and scrolling), 16-bit signed big-endian integers are used.

Returns the command and the number of bytes that were read from the buffer.

Arguments

  • buf - The byte buffer to read from.

Examples

use tfc::{Command, CommandCode, Key};

let bytes = &[
    CommandCode::MouseMoveRel as u8, 255, 214, 0, 64,
    CommandCode::KeyClick as u8, Key::K as u8
];

let (command, len) = Command::from_bytes(bytes).unwrap();
assert_eq!(len, 5);
assert_eq!(command, Command::MouseMoveRel(-42, 64));

let bytes = &bytes[len..];
let (command, len) = Command::from_bytes(bytes).unwrap();
assert_eq!(len, 2);
assert_eq!(command, Command::KeyClick(Key::K));

pub fn execute<C>(&self, ctx: &mut C) -> Result<(), Error> where
    C: KeyboardContext + MouseContext
[src]

Execute a Command by calling the corresponding method on one of the traits.

Trait Implementations

impl Debug for Command[src]

impl Eq for Command[src]

impl PartialEq<Command> for Command[src]

impl StructuralEq for Command[src]

impl StructuralPartialEq for Command[src]

Auto Trait Implementations

impl RefUnwindSafe for Command

impl Send for Command

impl Sync for Command

impl Unpin for Command

impl UnwindSafe for Command

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.