INNER CODE UNIT · Rust
configured_api_port
shenmintao/marginalia · desktop/src-tauri/src/lib.rs:206
fn configured_api_port(home: &Path) -> Option<u16> {
configured_env_value(home, "MARGINALIA_API_PORT").and_then(|value| match value.parse::<u16>() {
Ok(port) => Some(port),
Err(e) => {
log::warn!("ignoring invalid MARGINALIA_API_PORT={}: {}", value, e);
None
}
})
}
fn client_base_url(host: &str, port: u16) -> String {
let mut client_host = host.trim();
if client_host.is_empty() || client_host == "0.0.0.0" || client_host == "::" {
client_host = "127.0.0.1";
}
if client_host.contains(':') && !client_host.starts_with('[') {
format!("http://[{}]:{}", client_host, port)
} else {