pub async fn run_client(args: Args) -> Result<()>Expand description
Creates and runs a terminal sharing session
This is the main entry point for the client functionality. It performs the following steps:
- Server Validation: Verifies connectivity to the tunnel server
- Session Registration: Creates a new session with authentication settings
- PTY Creation: Spawns a pseudo-terminal with the user’s shell
- WebSocket Connection: Establishes connection to tunnel server
- I/O Forwarding: Bidirectional data flow between terminal and web clients
- Event Handling: Manages terminal resizing, user input, and process lifecycle
§Arguments
args- Configuration including server addresses, passwords, and permissions
§Returns
Result<()>- Success or error result
§Example
use tshare::client::{Args, run_client};
let args = Args {
tunnel_host: "localhost".to_string(),
tunnel_port: 8385,
web_host: "localhost".to_string(),
web_port: 8386,
owner_pass: Some("secret123".to_string()),
guest_pass: None,
guest_readonly: false,
};
run_client(args).await?;§Behavior
The function will:
- Display a shareable web link after successful session creation
- Enable raw terminal mode for real-time character input
- Forward all terminal I/O to connected web viewers
- Handle terminal resize events from web clients
- Clean up resources and exit when the terminal session ends
§Panics
Will panic if:
- The tunnel server is unreachable
- The tunnel server returns unexpected responses
- Critical initialization steps fail