MCPcopy Create free account
hub / github.com/algoscienceacademy/RustUI / open_browser

Method open_browser

src/dev_server.rs:529–554  ·  view source on GitHub ↗
(&self, browser: &str, port: u16)

Source from the content-addressed store, hash-verified

527 }
528
529 fn open_browser(&self, browser: &str, port: u16) -> Result<(), Box<dyn std::error::Error>> {
530 let url = format!("http://localhost:{}", port);
531
532 #[cfg(target_os = "macos")]
533 {
534 Command::new("open")
535 .args(["-a", browser, &url])
536 .spawn()?;
537 }
538
539 #[cfg(target_os = "linux")]
540 {
541 Command::new("xdg-open")
542 .arg(&url)
543 .spawn()?;
544 }
545
546 #[cfg(target_os = "windows")]
547 {
548 Command::new("cmd")
549 .args(["/C", "start", &url])
550 .spawn()?;
551 }
552
553 Ok(())
554 }
555
556 fn open_default_browser(&self, port: u16) -> Result<(), Box<dyn std::error::Error>> {
557 let url = format!("http://localhost:{}", port);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected