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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
use super::{ManagerAuthenticationId, ManagerChannelId};
use crate::common::{
    authentication::msg::AuthenticationResponse, ConnectionId, Destination, Map, UntypedRequest,
};
use derive_more::IsVariant;
use serde::{Deserialize, Serialize};
use strum::{AsRefStr, EnumDiscriminants, EnumIter, EnumMessage, EnumString};

#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, EnumDiscriminants, Serialize, Deserialize)]
#[strum_discriminants(derive(
    AsRefStr,
    strum::Display,
    EnumIter,
    EnumMessage,
    EnumString,
    Hash,
    PartialOrd,
    Ord,
    IsVariant,
    Serialize,
    Deserialize
))]
#[cfg_attr(
    feature = "schemars",
    strum_discriminants(derive(schemars::JsonSchema))
)]
#[strum_discriminants(name(ManagerCapabilityKind))]
#[strum_discriminants(strum(serialize_all = "snake_case"))]
#[serde(rename_all = "snake_case", deny_unknown_fields, tag = "type")]
pub enum ManagerRequest {
    /// Retrieve information about the server's capabilities
    #[strum_discriminants(strum(message = "Supports retrieving capabilities"))]
    Capabilities,

    /// Launch a server using the manager
    #[strum_discriminants(strum(message = "Supports launching a server on remote machines"))]
    Launch {
        // NOTE: Boxed per clippy's large_enum_variant warning
        destination: Box<Destination>,

        /// Additional options specific to the connection
        options: Map,
    },

    /// Initiate a connection through the manager
    #[strum_discriminants(strum(message = "Supports connecting to remote servers"))]
    Connect {
        // NOTE: Boxed per clippy's large_enum_variant warning
        destination: Box<Destination>,

        /// Additional options specific to the connection
        options: Map,
    },

    /// Submit some authentication message for the manager to use with an active connection
    #[strum_discriminants(strum(message = "Supports authenticating with a remote server"))]
    Authenticate {
        /// Id of the authentication request that is being responded to
        id: ManagerAuthenticationId,

        /// Response being sent to some active connection
        msg: AuthenticationResponse,
    },

    /// Opens a channel for communication with an already-connected server
    #[strum_discriminants(strum(message = "Supports opening a channel with a remote server"))]
    OpenChannel {
        /// Id of the connection
        id: ConnectionId,
    },

    /// Sends data through channel
    #[strum_discriminants(strum(
        message = "Supports sending data through a channel with a remote server"
    ))]
    Channel {
        /// Id of the channel
        id: ManagerChannelId,

        /// Untyped request to send through the channel
        request: UntypedRequest<'static>,
    },

    /// Closes an open channel
    #[strum_discriminants(strum(message = "Supports closing a channel with a remote server"))]
    CloseChannel {
        /// Id of the channel to close
        id: ManagerChannelId,
    },

    /// Retrieve information about a specific connection
    #[strum_discriminants(strum(message = "Supports retrieving connection-specific information"))]
    Info { id: ConnectionId },

    /// Kill a specific connection
    #[strum_discriminants(strum(message = "Supports killing a remote connection"))]
    Kill { id: ConnectionId },

    /// Retrieve list of connections being managed
    #[strum_discriminants(strum(message = "Supports retrieving a list of managed connections"))]
    List,
}