Common/WorkSpace/WorkSpaceEditApplier.rs
1//! # WorkSpaceEditApplier Trait
2//!
3//! Defines the `WorkSpaceEditApplier` trait for applying batch edits across
4//! the workspace.
5
6use async_trait::async_trait;
7
8// Note: WorkSpaceEditDTO is defined in `language_feature::DTO` as it's
9// most commonly used there, but it is a general-purpose DTO.
10use crate::DTO::WorkSpaceEditDTO::WorkSpaceEditDTO;
11use crate::{Environment::Environment::Environment, Error::CommonError::CommonError};
12
13/// An abstract service contract for an environment component that can apply a
14/// `WorkSpaceEdit`.
15///
16/// A `WorkSpaceEdit` is a complex, potentially transactional operation that can
17/// include text edits to multiple files, as well as file system operations like
18/// creating, deleting, or renaming files. This trait isolates the complex
19/// logic of applying such edits.
20#[async_trait]
21pub trait WorkSpaceEditApplier: Environment + Send + Sync {
22 /// Applies the given `WorkSpaceEditDTO` to the workspace.
23 ///
24 /// # Parameters
25 /// * `EditDTO`: The DTO representing the batch of edits to apply.
26 ///
27 /// # Returns
28 /// A `Result` indicating whether the entire edit was applied
29 /// successfully. A `false` value may indicate a partial success or a user
30 /// cancellation of one of the steps.
31 async fn ApplyWorkSpaceEdit(&self, EditDTO:WorkSpaceEditDTO) -> Result<bool, CommonError>;
32}