diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-06 17:21:49 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-06 17:21:49 +0800 |
| commit | c1d862d6df58173c24604e4dda33db8ce3be3ad7 (patch) | |
| tree | 171ecf07053748ce7493efaeff5eefbc8645b2cb /crates/system_action/src/action.rs | |
| parent | 66a32a8584cf34a881ec45f47d379fb3b1637033 (diff) | |
| parent | e12f167de8e16baa78c86b09eab75201281d3f95 (diff) | |
Merge pull request #19 from JustEnoughVCS/jvcs_dev
Jvcs dev
Diffstat (limited to 'crates/system_action/src/action.rs')
| -rw-r--r-- | crates/system_action/src/action.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/crates/system_action/src/action.rs b/crates/system_action/src/action.rs index 14f1148..562a142 100644 --- a/crates/system_action/src/action.rs +++ b/crates/system_action/src/action.rs @@ -11,13 +11,30 @@ pub trait Action<Args, Return> { ) -> impl std::future::Future<Output = Result<Return, TcpTargetError>> + Send; } +#[derive(Default)] pub struct ActionContext { // Whether the action is executed locally or remotely local: bool, /// The connection instance in the current context, /// used to interact with the machine on the other end - instance: ConnectionInstance, + instance: Option<ConnectionInstance>, +} + +impl ActionContext { + /// Generate local context + pub fn local() -> Self { + let mut ctx = ActionContext::default(); + ctx.local = true; + ctx + } + + /// Generate remote context + pub fn remote() -> Self { + let mut ctx = ActionContext::default(); + ctx.local = false; + ctx + } } impl ActionContext { @@ -32,7 +49,7 @@ impl ActionContext { } /// Get the connection instance in the current context - pub fn instance(&self) -> &ConnectionInstance { + pub fn instance(&self) -> &Option<ConnectionInstance> { &self.instance } } |
