1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use self::Side::{Client, Server};

/// Side to generate
///
/// This enum represents the two possible sides of
/// the protocol API that can be generated.
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Side {
    /// wayland client applications
    Client,
    /// wayland compositors
    Server,
}

#[doc(hidden)]
impl Side {
    pub fn object_ptr_type(&self) -> &'static str {
        match *self {
            Client => "wl_proxy",
            Server => "wl_resource",
        }
    }

    pub fn object_trait(&self) -> &'static str {
        match *self {
            Client => "Proxy",
            Server => "Resource",
        }
    }

    pub fn handle_type(&self) -> &'static str {
        match *self {
            Client => "EventQueueHandle",
            Server => "EventLoopHandle",
        }
    }

    pub fn handle(&self) -> &'static str {
        match *self {
            Client => "WAYLAND_CLIENT_HANDLE",
            Server => "WAYLAND_SERVER_HANDLE",
        }
    }

    pub fn result_type(&self) -> &'static str {
        match *self {
            Client => "RequestResult",
            Server => "EventResult",
        }
    }
}