diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-29 15:28:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-29 15:28:50 +0800 |
| commit | 4f35da85641549c3e08c4e1b73fccfc7ec9779a2 (patch) | |
| tree | 360a7c95183bc9800f95fdb34e162383f66daffa /crates/system_action/src/action.rs | |
| parent | 23784691ed4668e4e308fb5af70c2574f5936346 (diff) | |
| parent | 50945b098e3f6ff16f3f4cf25c2835ddf1e7b3a8 (diff) | |
Merge pull request #29 from JustEnoughVCS/jvcs_dev_actions
Jvcs dev actions
Diffstat (limited to 'crates/system_action/src/action.rs')
| -rw-r--r-- | crates/system_action/src/action.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/system_action/src/action.rs b/crates/system_action/src/action.rs index 9eef1db..ef1bf11 100644 --- a/crates/system_action/src/action.rs +++ b/crates/system_action/src/action.rs @@ -130,17 +130,27 @@ impl ActionContext { } /// Insert arbitrary data in the context - pub fn insert<T: Any + Send + Sync>(mut self, value: T) -> Self { + pub fn with_data<T: Any + Send + Sync>(mut self, value: T) -> Self { self.data.insert(TypeId::of::<T>(), Arc::new(value)); self } /// Insert arbitrary data as Arc in the context - pub fn insert_arc<T: Any + Send + Sync>(mut self, value: Arc<T>) -> Self { + pub fn with_arc_data<T: Any + Send + Sync>(mut self, value: Arc<T>) -> Self { self.data.insert(TypeId::of::<T>(), value); self } + /// Insert arbitrary data in the context + pub fn insert_data<T: Any + Send + Sync>(&mut self, value: T) { + self.data.insert(TypeId::of::<T>(), Arc::new(value)); + } + + /// Insert arbitrary data as Arc in the context + pub fn insert_arc_data<T: Any + Send + Sync>(&mut self, value: Arc<T>) { + self.data.insert(TypeId::of::<T>(), value); + } + /// Get arbitrary data from the context pub fn get<T: Any + Send + Sync>(&self) -> Option<&T> { self.data |
