Common/Command/
UnregisterCommand.rs

1//! # UnregisterCommand Effect
2//!
3//! Defines the `ActionEffect` for unregistering a previously registered
4//! command.
5
6use std::sync::Arc;
7
8use super::CommandExecutor::CommandExecutor;
9use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
10
11/// Creates an effect that, when executed, will unregister a command from the
12/// host's command registry.
13///
14/// This is typically called when an extension is deactivated or explicitly
15/// disposes of a command registration.
16///
17/// # Parameters
18///
19/// * `SideCarIdentifier`: The unique ID of the sidecar that originally
20///   registered the command.
21/// * `CommandIdentifier`: The unique ID of the command to unregister.
22///
23/// # Returns
24///
25/// An `ActionEffect` that resolves to `()` on success.
26pub fn UnregisterCommand(
27	SideCarIdentifier:String,
28
29	CommandIdentifier:String,
30) -> ActionEffect<Arc<dyn CommandExecutor>, CommonError, ()> {
31	ActionEffect::New(Arc::new(move |Executor:Arc<dyn CommandExecutor>| {
32		let SideCarIdentifierClone = SideCarIdentifier.clone();
33
34		let CommandIdentifierClone = CommandIdentifier.clone();
35
36		Box::pin(async move { Executor.UnregisterCommand(SideCarIdentifierClone, CommandIdentifierClone).await })
37	}))
38}