Enum tfc::Command [−][src]
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
Corresponds to mouse_move_rel
Corresponds to mouse_move_abs
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]
C: KeyboardContext + MouseContext,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,