Common/SourceControlManagement/SourceControlManagementProvider.rs
1// File: Common/Source/SourceControlManagement/SourceControlManagementProvider.
2// rs Role: Defines the abstract service trait for Source Control Management
3// (SourceControlManagement). Responsibilities:
4// - Provide a contract for creating and managing SourceControlManagement
5// providers.
6// - Provide a contract for updating SourceControlManagement groups and their
7// resources.
8// - Provide a contract for managing the SourceControlManagement input box.
9
10//! # SourceControlManagementProvider Trait
11//!
12//! Defines the abstract service trait for integrating with source control
13//! management systems like Git.
14
15use async_trait::async_trait;
16use serde_json::Value;
17
18use crate::{Environment::Environment::Environment, Error::CommonError::CommonError};
19
20/// An abstract service contract for an environment component that can manage
21/// Source Control Management (SourceControlManagement) providers contributed by
22/// extensions.
23#[async_trait]
24pub trait SourceControlManagementProvider: Environment + Send + Sync {
25 /// Creates a new SourceControlManagement provider in the host.
26 ///
27 /// # Parameters
28 /// * `ProviderData`: A DTO containing metadata about the provider, such as
29 /// its ID, label, and root URI.
30 ///
31 /// # Returns
32 /// A `Result` containing a unique handle (`u32`) for the new provider.
33 async fn CreateSourceControl(
34 &self,
35
36 // DTO: SourceControlCreateDTO
37 ProviderData:Value,
38 ) -> Result<u32, CommonError>;
39
40 /// Disposes of an SourceControlManagement provider, removing it and its
41 /// groups from the UI.
42 ///
43 /// # Parameters
44 /// * `ProviderHandle`: The handle of the SourceControlManagement provider
45 /// to dispose.
46 async fn DisposeSourceControl(&self, ProviderHandle:u32) -> Result<(), CommonError>;
47
48 /// Updates the core properties of an SourceControlManagement provider.
49 ///
50 /// This is used to update properties like the commit message template, the
51 /// count badge, and the accept command.
52 ///
53 /// # Parameters
54 /// * `ProviderHandle`: The handle of the provider to update.
55 /// * `UpdateData`: A DTO containing the properties to update.
56 async fn UpdateSourceControl(
57 &self,
58
59 ProviderHandle:u32,
60
61 // DTO: SourceControlUpdateDTO
62 UpdateData:Value,
63 ) -> Result<(), CommonError>;
64
65 /// Updates the properties of an SourceControlManagement resource group
66 /// (e.g., "Changes").
67 ///
68 /// This can update the group's label, hide state, and its list of
69 /// resources.
70 ///
71 /// # Parameters
72 /// * `ProviderHandle`: The handle of the SourceControlManagement provider
73 /// that owns the group.
74 /// * `GroupData`: A DTO containing the updated state of the group.
75 async fn UpdateSourceControlGroup(
76 &self,
77
78 ProviderHandle:u32,
79
80 // DTO: SourceControlGroupUpdateDTO
81 GroupData:Value,
82 ) -> Result<(), CommonError>;
83
84 /// Registers or updates the SourceControlManagement input box for a
85 /// provider.
86 ///
87 /// # Parameters
88 /// * `ProviderHandle`: The handle of the SourceControlManagement provider.
89 /// * `InputBoxData`: A DTO containing the state of the input box (e.g.,
90
91 /// value, placeholder).
92 async fn RegisterInputBox(
93 &self,
94
95 ProviderHandle:u32,
96
97 // DTO: SourceControlInputBoxDTO
98 InputBoxData:Value,
99 ) -> Result<(), CommonError>;
100}