Skip to main content

response/
response.rs

1use little_kitty::*;
2
3fn main() {
4    println!("Kitty supported: {}", Command::is_supported().expect("is_supported"));
5
6    // This query should always return OK
7
8    let response = Command::default()
9        // Action = query
10        .with_control('a', 'q')
11        // Image ID
12        .with_control('i', 1)
13        .with_expect_response()
14        .execute()
15        .expect("execute")
16        .expect("response");
17
18    if response.is_ok() {
19        println!("OK!");
20    }
21
22    // This command should always return an error
23
24    let response = Command::default()
25        // Image ID
26        .with_control('i', 1)
27        // Transmission medium = shared memory object
28        .with_control('t', 's')
29        .with_expect_response()
30        .execute_with_payload(b"not a shared memory object")
31        .expect("execute_with_payload")
32        .expect("response");
33
34    println!("Error: {}", response.message.expect("message"));
35}