distant_net/manager/data/response.rs
1use distant_auth::msg::Authentication;
2use serde::{Deserialize, Serialize};
3
4use super::{ConnectionInfo, ConnectionList, ManagerAuthenticationId, ManagerChannelId, SemVer};
5use crate::common::{ConnectionId, Destination, UntypedResponse};
6
7#[derive(Clone, Debug, Serialize, Deserialize)]
8#[serde(rename_all = "snake_case", deny_unknown_fields, tag = "type")]
9pub enum ManagerResponse {
10 /// Acknowledgement that a connection was killed
11 Killed,
12
13 /// Indicates that some error occurred during a request
14 Error { description: String },
15
16 /// Information about the manager's version.
17 Version { version: SemVer },
18
19 /// Confirmation of a server being launched
20 Launched {
21 /// Updated location of the spawned server
22 destination: Destination,
23 },
24
25 /// Confirmation of a connection being established
26 Connected { id: ConnectionId },
27
28 /// Authentication information being sent to a client
29 Authenticate {
30 /// Id tied to authentication information in case a response is needed
31 id: ManagerAuthenticationId,
32
33 /// Authentication message
34 msg: Authentication,
35 },
36
37 /// Information about a specific connection
38 Info(ConnectionInfo),
39
40 /// List of connections in the form of id -> destination
41 List(ConnectionList),
42
43 /// Forward a response back to a specific channel that made a request
44 Channel {
45 /// Id of the channel
46 id: ManagerChannelId,
47
48 /// Untyped response to send through the channel
49 response: UntypedResponse<'static>,
50 },
51
52 /// Indicates that a channel has been opened
53 ChannelOpened {
54 /// Id of the channel
55 id: ManagerChannelId,
56 },
57
58 /// Indicates that a channel has been closed
59 ChannelClosed {
60 /// Id of the channel
61 id: ManagerChannelId,
62 },
63}
64
65impl<T: std::error::Error> From<T> for ManagerResponse {
66 fn from(x: T) -> Self {
67 Self::Error {
68 description: x.to_string(),
69 }
70 }
71}