Skip to content

Commit 752cc09

Browse files
style(SideCar): Reformat function signatures and comments in Spawn modules
Remove extra spaces after colons in function parameter types and comments across Spawn.rs and main.rs. This standardizes the formatting to match the codebase style guidelines. Changes include: - `app: &AppHandle` → `app:&AppHandle` - `sidecar_name: &str` → `sidecar_name:&str` - Updated doc comments to match the new formatting
1 parent 1e1925b commit 752cc09

File tree

3 files changed

+70
-67
lines changed

3 files changed

+70
-67
lines changed

Source/Source/SideCar/Spawn.rs

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1+
use std::fs;
2+
13
#[allow(unused_imports)]
24
use tauri::{AppHandle, Manager};
3-
use std::fs;
45
use Mist::dns_port;
56

6-
const DNS_OVERRIDE: &str = include_str!("../../../Resource/dns-override.js");
7+
const DNS_OVERRIDE:&str = include_str!("../../../Resource/dns-override.js");
78

8-
/// Spawns a Node.js sidecar with DNS override configured to use the local Hickory DNS server.
9+
/// Spawns a Node.js sidecar with DNS override configured to use the local
10+
/// Hickory DNS server.
911
///
1012
/// This function:
1113
/// 1. Creates the app data directory if it doesn't exist
1214
/// 2. Writes the DNS override JavaScript file to the app data directory
13-
/// 3. Configures the sidecar process with NODE_OPTIONS to require the DNS override script
14-
/// 4. Sets the LAND_DNS_SERVER environment variable with the local DNS server address
15+
/// 3. Configures the sidecar process with NODE_OPTIONS to require the DNS
16+
/// override script
17+
/// 4. Sets the LAND_DNS_SERVER environment variable with the local DNS server
18+
/// address
1519
/// 5. Spawns the sidecar process
1620
///
1721
/// # Parameters
1822
///
19-
/// * `app` - The Tauri app handle, used to access the app data directory and shell
23+
/// * `app` - The Tauri app handle, used to access the app data directory and
24+
/// shell
2025
/// * `sidecar_name` - The name of the sidecar executable to spawn
2126
///
2227
/// # Returns
@@ -33,35 +38,31 @@ const DNS_OVERRIDE: &str = include_str!("../../../Resource/dns-override.js");
3338
/// use SideCar::Spawn::spawn_node_sidecar;
3439
///
3540
/// #[tauri::command]
36-
/// fn launch_sidecar(app: tauri::AppHandle) -> Result<(), String> {
37-
/// spawn_node_sidecar(&app, "my-sidecar")
38-
/// .map_err(|e| e.to_string())?;
39-
/// Ok(())
41+
/// fn launch_sidecar(app:tauri::AppHandle) -> Result<(), String> {
42+
/// spawn_node_sidecar(&app, "my-sidecar").map_err(|e| e.to_string())?;
43+
/// Ok(())
4044
/// }
4145
/// ```
4246
#[allow(dead_code)]
43-
pub fn spawn_node_sidecar(
44-
app: &AppHandle,
45-
sidecar_name: &str,
46-
) -> anyhow::Result<()> {
47-
// Ensure app data directory exists
48-
let data_dir = app.path().app_data_dir()?;
49-
fs::create_dir_all(&data_dir)?;
47+
pub fn spawn_node_sidecar(app:&AppHandle, sidecar_name:&str) -> anyhow::Result<()> {
48+
// Ensure app data directory exists
49+
let data_dir = app.path().app_data_dir()?;
50+
fs::create_dir_all(&data_dir)?;
5051

51-
// Write DNS override script to app data directory
52-
let override_path = data_dir.join("dns-override.js");
53-
fs::write(&override_path, DNS_OVERRIDE)?;
52+
// Write DNS override script to app data directory
53+
let override_path = data_dir.join("dns-override.js");
54+
fs::write(&override_path, DNS_OVERRIDE)?;
5455

55-
// Get the DNS server port from Mist module
56-
let port = dns_port();
57-
let node_opts = format!("--require {}", override_path.display());
56+
// Get the DNS server port from Mist module
57+
let port = dns_port();
58+
let node_opts = format!("--require {}", override_path.display());
5859

59-
// Spawn the sidecar with DNS configuration
60-
app.shell()
61-
.sidecar(sidecar_name)?
62-
.env("NODE_OPTIONS", &node_opts)
63-
.env("LAND_DNS_SERVER", format!("127.0.0.1:{port}"))
64-
.spawn()?;
60+
// Spawn the sidecar with DNS configuration
61+
app.shell()
62+
.sidecar(sidecar_name)?
63+
.env("NODE_OPTIONS", &node_opts)
64+
.env("LAND_DNS_SERVER", format!("127.0.0.1:{port}"))
65+
.spawn()?;
6566

66-
Ok(())
67+
Ok(())
6768
}

Source/Spawn.rs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,35 @@
11
// DEPENDENCY: This module file was created to resolve a missing module error.
2-
// The original Spawn.rs was located at Source/Source/SideCar/Spawn.rs in an unusual directory structure.
3-
// Consider refactoring the directory structure to avoid duplicate/confusing module locations.
2+
// The original Spawn.rs was located at Source/Source/SideCar/Spawn.rs in an
3+
// unusual directory structure. Consider refactoring the directory structure to
4+
// avoid duplicate/confusing module locations.
5+
6+
use std::fs;
47

58
#[allow(unused_imports)]
69
use tauri::{AppHandle, Manager};
7-
use std::fs;
810
// Note: Mist crate has lib name "mist", so we use lowercase for imports
911
use mist::dns_port;
1012
// DEPENDENCY: Add tauri-plugin-shell to Cargo.toml dependencies for Tauri 2.x shell support
1113
use tauri_plugin_shell::ShellExt;
1214

13-
const DNS_OVERRIDE: &str = include_str!("../Resource/dns-override.js");
15+
const DNS_OVERRIDE:&str = include_str!("../Resource/dns-override.js");
1416

15-
/// Spawns a Node.js sidecar with DNS override configured to use the local Hickory DNS server.
17+
/// Spawns a Node.js sidecar with DNS override configured to use the local
18+
/// Hickory DNS server.
1619
///
1720
/// This function:
1821
/// 1. Creates the app data directory if it doesn't exist
1922
/// 2. Writes the DNS override JavaScript file to the app data directory
20-
/// 3. Configures the sidecar process with NODE_OPTIONS to require the DNS override script
21-
/// 4. Sets the LAND_DNS_SERVER environment variable with the local DNS server address
23+
/// 3. Configures the sidecar process with NODE_OPTIONS to require the DNS
24+
/// override script
25+
/// 4. Sets the LAND_DNS_SERVER environment variable with the local DNS server
26+
/// address
2227
/// 5. Spawns the sidecar process
2328
///
2429
/// # Parameters
2530
///
26-
/// * `app` - The Tauri app handle, used to access the app data directory and shell
31+
/// * `app` - The Tauri app handle, used to access the app data directory and
32+
/// shell
2733
/// * `sidecar_name` - The name of the sidecar executable to spawn
2834
///
2935
/// # Returns
@@ -40,35 +46,31 @@ const DNS_OVERRIDE: &str = include_str!("../Resource/dns-override.js");
4046
/// use SideCar::Spawn::spawn_node_sidecar;
4147
///
4248
/// #[tauri::command]
43-
/// fn launch_sidecar(app: tauri::AppHandle) -> Result<(), String> {
44-
/// spawn_node_sidecar(&app, "my-sidecar")
45-
/// .map_err(|e| e.to_string())?;
46-
/// Ok(())
49+
/// fn launch_sidecar(app:tauri::AppHandle) -> Result<(), String> {
50+
/// spawn_node_sidecar(&app, "my-sidecar").map_err(|e| e.to_string())?;
51+
/// Ok(())
4752
/// }
4853
/// ```
4954
#[allow(dead_code)]
50-
pub fn spawn_node_sidecar(
51-
app: &AppHandle,
52-
sidecar_name: &str,
53-
) -> anyhow::Result<()> {
54-
// Ensure app data directory exists
55-
let data_dir = app.path().app_data_dir()?;
56-
fs::create_dir_all(&data_dir)?;
55+
pub fn spawn_node_sidecar(app:&AppHandle, sidecar_name:&str) -> anyhow::Result<()> {
56+
// Ensure app data directory exists
57+
let data_dir = app.path().app_data_dir()?;
58+
fs::create_dir_all(&data_dir)?;
5759

58-
// Write DNS override script to app data directory
59-
let override_path = data_dir.join("dns-override.js");
60-
fs::write(&override_path, DNS_OVERRIDE)?;
60+
// Write DNS override script to app data directory
61+
let override_path = data_dir.join("dns-override.js");
62+
fs::write(&override_path, DNS_OVERRIDE)?;
6163

62-
// Get the DNS server port from Mist module
63-
let port = dns_port();
64-
let node_opts = format!("--require {}", override_path.display());
64+
// Get the DNS server port from Mist module
65+
let port = dns_port();
66+
let node_opts = format!("--require {}", override_path.display());
6567

66-
// Spawn the sidecar with DNS configuration
67-
app.shell()
68-
.sidecar(sidecar_name)?
69-
.env("NODE_OPTIONS", &node_opts)
70-
.env("LAND_DNS_SERVER", format!("127.0.0.1:{port}"))
71-
.spawn()?;
68+
// Spawn the sidecar with DNS configuration
69+
app.shell()
70+
.sidecar(sidecar_name)?
71+
.env("NODE_OPTIONS", &node_opts)
72+
.env("LAND_DNS_SERVER", format!("127.0.0.1:{port}"))
73+
.spawn()?;
7274

73-
Ok(())
75+
Ok(())
7476
}

Source/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//! It calls the main function from the library.
55
66
fn main() {
7-
// DEPENDENCY: Move the main function from Library.rs here in a future refactor
8-
// Currently Library.rs contains both lib and binary code
9-
// For now, delegate to the library's main function
10-
use SideCar::main as lib_main;
11-
lib_main();
7+
// DEPENDENCY: Move the main function from Library.rs here in a future refactor
8+
// Currently Library.rs contains both lib and binary code
9+
// For now, delegate to the library's main function
10+
use SideCar::main as lib_main;
11+
lib_main();
1212
}

0 commit comments

Comments
 (0)