Skip to content

refactor: pass SshHost and password by reference to engine functions#132

Merged
Cleboost merged 1 commit into
masterfrom
refactor/pass-by-reference
May 10, 2026
Merged

refactor: pass SshHost and password by reference to engine functions#132
Cleboost merged 1 commit into
masterfrom
refactor/pass-by-reference

Conversation

@Cleboost
Copy link
Copy Markdown
Owner

This pull request refactors the SSH and SFTP interface functions to consistently use references for host, password, and path parameters, instead of passing owned values. This change improves efficiency by avoiding unnecessary cloning and allocations, and ensures more consistent API usage throughout the codebase. All call sites in the UI and logic layers are updated to match the new function signatures.

API Refactoring and Consistency:

  • All SFTP and SSH-related functions in src/sftp_engine.rs and src/ssh_engine.rs now take parameters as references (e.g., &SshHost, Option<&str>, &str) instead of owned values, reducing unnecessary cloning and allocations. [1] [2]
  • Updated internal logic to convert referenced strings to owned values only when needed for blocking tasks, ensuring minimal allocations. [1] [2]

UI Integration Updates:

  • All calls to SFTP and SSH functions in src/ui/file_explorer.rs and src/ui/docker.rs are updated to pass references and use .as_deref() for optional passwords, ensuring compatibility with the new function signatures. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

Authentication Handling:

  • Passwords are now cloned only when necessary for authentication, improving clarity and reducing redundant allocations in establish_ssh_session. [1] [2]

Overall, these changes make the codebase more efficient and idiomatic by leveraging references and reducing unnecessary data copying, while also simplifying the integration points in the UI code.

@Cleboost Cleboost merged commit d31c7ae into master May 10, 2026
1 check passed
@Cleboost Cleboost deleted the refactor/pass-by-reference branch May 10, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant