Skip to main content

ConnectionManager

Struct ConnectionManager 

Source
pub struct ConnectionManager { /* private fields */ }
Expand description

The connection manager owns the mapping from connection_id → its backing protocol state. Previously this was eight parallel hashmaps held together by convention; invariants (e.g. “if connection_types says SFTP, the sftp hashmap contains the id”) are now enforced by the variant tag itself.

Implementations§

Source§

impl ConnectionManager

Source

pub fn new() -> Self

Source

pub fn with_host_keys(host_keys: Arc<HostKeyStore>) -> Self

Source

pub fn host_keys(&self) -> Arc<HostKeyStore>

Access the shared host-key store. Used by the macOS bridge to expose forget over FFI for the “Trust new key” flow on a HostKeyMismatch.

Source

pub async fn connection_kind(&self, id: &str) -> Option<ProtocolKind>

Protocol of an existing connection, or None if not registered.

Source

pub async fn get_connection_type(&self, id: &str) -> Option<String>

Backward-compatible string form of connection_kind. Returns “SSH”, “SFTP”, “FTP”, “RDP”, or “VNC”. Prefer connection_kind in new code.

Source

pub async fn list_connections(&self) -> Vec<String>

Source

pub async fn get_connection(&self, id: &str) -> Option<Arc<RwLock<SshClient>>>

Return the SSH client for a connection if it is an SSH connection.

Source

pub async fn get_sftp_client( &self, id: &str, ) -> Option<Arc<RwLock<StandaloneSftpClient>>>

Source

pub async fn get_ftp_client(&self, id: &str) -> Option<Arc<RwLock<FtpClient>>>

Source

pub async fn get_desktop_connection( &self, id: &str, ) -> Option<Arc<RwLock<Box<dyn DesktopProtocol>>>>

Source

pub async fn get_postgres_pool(&self, id: &str) -> Option<Arc<PgPool>>

Source

pub async fn create_connection( &self, connection_id: String, config: SshConfig, ) -> Result<()>

Source

pub async fn cancel_pending_connection(&self, connection_id: &str) -> bool

Source

pub async fn close_connection(&self, connection_id: &str) -> Result<()>

Close the SSH connection for connection_id (if it is SSH). Also tears down any associated PTY session and prunes the generation counter so it cannot leak across reconnects.

Source

pub async fn start_pty_connection( &self, connection_id: &str, cols: u32, rows: u32, ) -> Result<u64>

Start a PTY shell connection (like ttyd does). Enables interactive commands: vim, less, more, top, htop, etc.

Source

pub async fn write_to_pty( &self, connection_id: &str, data: Vec<u8>, ) -> Result<()>

Send data to PTY (user input).

Backpressure: if the input channel is full we await send, preserving keystroke order.

Source

pub async fn get_pty_session( &self, connection_id: &str, ) -> Option<Arc<PtySession>>

Capture the active PtySession for a connection. Used by the macOS bridge to spawn an output-forwarder task that holds a stable handle to the session’s output_rx for the lifetime of that PTY, even if start_pty_connection is later called again for the same connection (which would replace the entry in pty_sessions).

Source

pub async fn read_pty_burst( &self, connection_id: &str, max_bytes: usize, ) -> Result<Vec<u8>>

Read a burst of PTY output — blocks until data arrives, then drains any additional already-queued chunks up to max_bytes.

Source

pub async fn close_pty_connection( &self, connection_id: &str, expected_gen: Option<u64>, ) -> Result<()>

Close PTY connection, but only if the generation matches.

Source

pub async fn get_pty_cancel_token( &self, connection_id: &str, ) -> Option<CancellationToken>

Get the cancellation token for a PTY session (used by WebSocket reader tasks).

Source

pub async fn resize_pty( &self, connection_id: &str, cols: u32, rows: u32, ) -> Result<()>

Resize PTY terminal (send window-change to remote SSH channel)

Source

pub async fn create_sftp_connection( &self, connection_id: String, config: SftpConfig, ) -> Result<()>

Source

pub async fn close_sftp_connection(&self, connection_id: &str) -> Result<()>

Source

pub async fn create_ftp_connection( &self, connection_id: String, config: FtpConfig, ) -> Result<()>

Source

pub async fn close_ftp_connection(&self, connection_id: &str) -> Result<()>

Source

pub async fn create_desktop_connection( &self, connection_id: String, request: &DesktopConnectRequest, ) -> Result<(u16, u16)>

Source

pub async fn close_desktop_connection(&self, connection_id: &str) -> Result<()>

Source

pub async fn create_postgres_connection( &self, connection_id: String, config: PgConfig, ) -> Result<()>

Source

pub async fn close_postgres_connection(&self, connection_id: &str) -> Result<()>

Source

pub async fn start_desktop_stream( &self, connection_id: &str, frame_tx: UnboundedSender<FrameUpdate>, cancel: CancellationToken, ) -> Result<()>

Start the frame update loop for a desktop connection.

Not yet wired up to the WebSocket server — kept here so the RDP/VNC stubs have a concrete dispatch point once the protocol clients gain real implementations. Remove the allow once a caller appears.

Trait Implementations§

Source§

impl Default for ConnectionManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more