Skip to main content

gglib_core/events/
remote.rs

1//! Constructors for the remote-tunnel events.
2//!
3//! Split from `mod.rs` for the file-size gate, the way the proxy
4//! constructors would have been had they arrived later. Nothing here is a
5//! secret: the ticket travels as its fingerprint and never whole, because
6//! the event stream is readable by any local GUI client.
7
8use super::AppEvent;
9
10impl AppEvent {
11    /// Create a [`AppEvent::RemoteEnabled`] event.
12    pub const fn remote_enabled(ticket_fingerprint: String) -> Self {
13        Self::RemoteEnabled { ticket_fingerprint }
14    }
15
16    /// Create a [`AppEvent::RemoteDisabled`] event.
17    pub const fn remote_disabled() -> Self {
18        Self::RemoteDisabled
19    }
20
21    /// Create a [`AppEvent::RemotePaired`] event.
22    pub const fn remote_paired(peer: Option<String>) -> Self {
23        Self::RemotePaired { peer }
24    }
25
26    /// Create a [`AppEvent::RemoteConnected`] event.
27    pub const fn remote_connected(port: u16) -> Self {
28        Self::RemoteConnected { port }
29    }
30
31    /// Create a [`AppEvent::RemoteDisconnected`] event.
32    pub const fn remote_disconnected() -> Self {
33        Self::RemoteDisconnected
34    }
35
36    /// Create a [`AppEvent::RemoteAway`] event.
37    pub const fn remote_away(port: u16) -> Self {
38        Self::RemoteAway { port }
39    }
40
41    /// Create a [`AppEvent::RemoteBack`] event.
42    pub const fn remote_back(port: u16) -> Self {
43        Self::RemoteBack { port }
44    }
45}