Skip to content

Instantly share code, notes, and snippets.

View lucasshiva's full-sized avatar

Lucas Silva lucasshiva

  • São Paulo, Brazil
  • 08:06 (UTC -03:00)
View GitHub Profile
@lucasshiva
lucasshiva / lib.rs
Last active August 22, 2025 02:17
Managing sidecar lifecycle in Tauri 2.
use std::net::TcpListener;
use std::sync::{Arc, Mutex};
use tauri::Manager;
use tauri_plugin_shell::ShellExt;
fn get_available_port() -> Result<u16, std::io::Error> {
let listener = TcpListener::bind("127.0.0.1:0")?;
let port = listener.local_addr()?.port();
Ok(port)
}