Common/WorkSpace/ApplyWorkSpaceEdit.rs
1//! # ApplyWorkSpaceEdit Effect
2//!
3//! Defines the `ActionEffect` for applying a complex, multi-file workspace
4//! edit.
5
6use std::sync::Arc;
7
8use super::WorkSpaceEditApplier::WorkSpaceEditApplier;
9use crate::{
10 DTO::WorkSpaceEditDTO::WorkSpaceEditDTO,
11 Effect::ActionEffect::ActionEffect,
12 Error::CommonError::CommonError,
13};
14
15/// Creates an effect that, when executed, will apply a `WorkSpaceEdit` to the
16/// workspace.
17///
18/// A `WorkSpaceEdit` is a batch of operations that can include text edits to
19/// multiple files and filesystem operations like creating, deleting, or
20/// renaming files. This effect uses the dedicated `WorkSpaceEditApplier`
21/// capability.
22///
23/// # Parameters
24/// * `EditDTO`: The `WorkSpaceEditDTO` representing the batch of edits to
25/// apply.
26///
27/// # Returns
28/// An `ActionEffect` that resolves with a `bool` indicating whether the entire
29/// edit was applied successfully.
30pub fn ApplyWorkSpaceEdit(EditDTO:WorkSpaceEditDTO) -> ActionEffect<Arc<dyn WorkSpaceEditApplier>, CommonError, bool> {
31 ActionEffect::New(Arc::new(move |Applier:Arc<dyn WorkSpaceEditApplier>| {
32 let EditDTOClone = EditDTO.clone();
33
34 Box::pin(async move { Applier.ApplyWorkSpaceEdit(EditDTOClone).await })
35 }))
36}