pub struct ServerInitResult {
pub servers: HashMap<String, LspServer>,
pub failures: Vec<ServerSpawnFailure>,
}Expand description
Result of attempting to spawn multiple LSP servers.
This type enables graceful degradation by collecting both successful initializations and failures. Use the helper methods to inspect the outcome and make decisions about how to proceed.
§Examples
use mcpls_core::lsp::ServerInitResult;
use mcpls_core::error::ServerSpawnFailure;
let mut result = ServerInitResult::new();
// Check for different scenarios
if result.all_failed() {
eprintln!("All servers failed to initialize");
} else if result.partial_success() {
println!("Some servers succeeded, some failed");
} else if result.has_servers() {
println!("All servers initialized successfully");
}Fields§
§servers: HashMap<String, LspServer>Successfully initialized servers (language_id -> server).
failures: Vec<ServerSpawnFailure>Failures that occurred during spawn attempts.
Implementations§
Source§impl ServerInitResult
impl ServerInitResult
Sourcepub fn has_servers(&self) -> bool
pub fn has_servers(&self) -> bool
Check if any servers were successfully initialized.
Returns true if at least one server is available for use.
Sourcepub fn all_failed(&self) -> bool
pub fn all_failed(&self) -> bool
Check if all attempted servers failed.
Returns true only if there were failures and no servers succeeded.
Returns false for empty results (no servers configured).
Sourcepub fn partial_success(&self) -> bool
pub fn partial_success(&self) -> bool
Check if some but not all servers failed.
Returns true if there are both successful servers and failures.
Sourcepub fn server_count(&self) -> usize
pub fn server_count(&self) -> usize
Get the number of successfully initialized servers.
Sourcepub fn failure_count(&self) -> usize
pub fn failure_count(&self) -> usize
Get the number of failures.
Sourcepub fn add_server(&mut self, language_id: String, server: LspServer)
pub fn add_server(&mut self, language_id: String, server: LspServer)
Add a successful server.
If a server with the same language_id already exists, it will be replaced.
Sourcepub fn add_failure(&mut self, failure: ServerSpawnFailure)
pub fn add_failure(&mut self, failure: ServerSpawnFailure)
Add a failure.