pub struct LaunchCommand { /* private fields */ }Expand description
The command of a server entry together with the consent to replace it.
Binds ServerCommand to ServerSelection so that ServerSelection::Auto
can only accompany a typescript-language-server command; the combination
rust-analyzer plus auto cannot be built. The fields are private, so a
command cannot be swapped without re-checking the selection: use
Self::retarget.
Reads like the ServerCommand it wraps (as_str, Display, AsRef,
comparison with &str).
§Examples
use mcpls_core::config::{LaunchCommand, ServerCommand, ServerSelection};
let tsls = ServerCommand::new("typescript-language-server").unwrap();
let auto = LaunchCommand::auto(tsls).unwrap();
assert_eq!(auto.selection(), ServerSelection::Auto);
let rust = ServerCommand::new("rust-analyzer").unwrap();
assert!(LaunchCommand::auto(rust.clone()).is_err());
assert!(LaunchCommand::explicit(rust).is_explicit());Implementations§
Source§impl LaunchCommand
impl LaunchCommand
Sourcepub const fn explicit(command: ServerCommand) -> Self
pub const fn explicit(command: ServerCommand) -> Self
command started exactly as written.
Sourcepub fn auto(command: ServerCommand) -> Result<Self, InvalidAutoSelection>
pub fn auto(command: ServerCommand) -> Result<Self, InvalidAutoSelection>
command that mcpls may replace with the native TypeScript server.
§Errors
InvalidAutoSelection unless command is typescript-language-server.
Sourcepub fn new(
command: ServerCommand,
selection: ServerSelection,
) -> Result<Self, InvalidAutoSelection>
pub fn new( command: ServerCommand, selection: ServerSelection, ) -> Result<Self, InvalidAutoSelection>
command with selection.
§Errors
InvalidAutoSelection for ServerSelection::Auto on a command that
is not typescript-language-server.
Sourcepub fn retarget(
self,
command: ServerCommand,
) -> Result<Self, InvalidAutoSelection>
pub fn retarget( self, command: ServerCommand, ) -> Result<Self, InvalidAutoSelection>
This launch with command in place of the current one, keeping the
selection.
§Errors
InvalidAutoSelection when the selection is auto and command is not
typescript-language-server.
Sourcepub const fn server_command(&self) -> &ServerCommand
pub const fn server_command(&self) -> &ServerCommand
The command as configured.
Sourcepub const fn selection(&self) -> ServerSelection
pub const fn selection(&self) -> ServerSelection
Whether mcpls may replace the command.
Sourcepub const fn is_explicit(&self) -> bool
pub const fn is_explicit(&self) -> bool
Whether the command is started exactly as written.
Trait Implementations§
Source§impl AsRef<OsStr> for LaunchCommand
impl AsRef<OsStr> for LaunchCommand
Source§impl AsRef<Path> for LaunchCommand
impl AsRef<Path> for LaunchCommand
Source§impl Clone for LaunchCommand
impl Clone for LaunchCommand
Source§impl Debug for LaunchCommand
impl Debug for LaunchCommand
Source§impl Display for LaunchCommand
impl Display for LaunchCommand
impl Eq for LaunchCommand
Source§impl From<ServerCommand> for LaunchCommand
impl From<ServerCommand> for LaunchCommand
Source§fn from(command: ServerCommand) -> Self
fn from(command: ServerCommand) -> Self
Source§impl PartialEq for LaunchCommand
impl PartialEq for LaunchCommand
Source§impl PartialEq<&str> for LaunchCommand
impl PartialEq<&str> for LaunchCommand
Source§impl PartialEq<str> for LaunchCommand
impl PartialEq<str> for LaunchCommand
impl StructuralPartialEq for LaunchCommand
Auto Trait Implementations§
impl Freeze for LaunchCommand
impl RefUnwindSafe for LaunchCommand
impl Send for LaunchCommand
impl Sync for LaunchCommand
impl Unpin for LaunchCommand
impl UnsafeUnpin for LaunchCommand
impl UnwindSafe for LaunchCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.