Skip to content

Commit 754c2e7

Browse files
authored
feat(core): finish mutable getters for Context (#1814)
1 parent 39f8f26 commit 754c2e7

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"tauri": patch
3+
---
4+
5+
Expose mutable getters for the rest of the public `Context` getters.
6+
* `pub fn assets_mut(&mut self) -> &mut Arc<A>`
7+
* `pub fn default_window_icon_mut(&mut self) -> &mut Option<Vec<u8>>`
8+
* `pub fn system_tray_icon_mut(&mut self) -> &mut Option<Icon>`
9+
* `pub fn package_info_mut(&mut self) -> &mut tauri::api::PackageInfo`

core/tauri/src/lib.rs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,24 +154,48 @@ impl<A: Assets> Context<A> {
154154
self.assets.clone()
155155
}
156156

157+
/// A mutable reference to the assets to be served directly by Tauri.
158+
#[inline(always)]
159+
pub fn assets_mut(&mut self) -> &mut Arc<A> {
160+
&mut self.assets
161+
}
162+
157163
/// The default window icon Tauri should use when creating windows.
158164
#[inline(always)]
159165
pub fn default_window_icon(&self) -> Option<&[u8]> {
160166
self.default_window_icon.as_deref()
161167
}
162168

163-
/// The icon to use use on the system tray UI.
169+
/// A mutable reference to the default window icon Tauri should use when creating windows.
170+
#[inline(always)]
171+
pub fn default_window_icon_mut(&mut self) -> &mut Option<Vec<u8>> {
172+
&mut self.default_window_icon
173+
}
174+
175+
/// The icon to use on the system tray UI.
164176
#[inline(always)]
165177
pub fn system_tray_icon(&self) -> Option<&Icon> {
166178
self.system_tray_icon.as_ref()
167179
}
168180

181+
/// A mutable reference to the icon to use on the system tray UI.
182+
#[inline(always)]
183+
pub fn system_tray_icon_mut(&mut self) -> &mut Option<Icon> {
184+
&mut self.system_tray_icon
185+
}
186+
169187
/// Package information.
170188
#[inline(always)]
171189
pub fn package_info(&self) -> &crate::api::PackageInfo {
172190
&self.package_info
173191
}
174192

193+
/// A mutable reference to the package information.
194+
#[inline(always)]
195+
pub fn package_info_mut(&mut self) -> &mut crate::api::PackageInfo {
196+
&mut self.package_info
197+
}
198+
175199
/// Create a new [`Context`] from the minimal required items.
176200
#[inline(always)]
177201
pub fn new(

0 commit comments

Comments
 (0)