feat(core): finish mutable getters for Context (#1814)

This commit is contained in:
chip 2021-05-13 08:50:45 -07:00 committed by GitHub
parent 39f8f26916
commit 754c2e766a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 1 deletions

View File

@ -0,0 +1,9 @@
---
"tauri": patch
---
Expose mutable getters for the rest of the public `Context` getters.
* `pub fn assets_mut(&mut self) -> &mut Arc<A>`
* `pub fn default_window_icon_mut(&mut self) -> &mut Option<Vec<u8>>`
* `pub fn system_tray_icon_mut(&mut self) -> &mut Option<Icon>`
* `pub fn package_info_mut(&mut self) -> &mut tauri::api::PackageInfo`

View File

@ -154,24 +154,48 @@ impl<A: Assets> Context<A> {
self.assets.clone()
}
/// A mutable reference to the assets to be served directly by Tauri.
#[inline(always)]
pub fn assets_mut(&mut self) -> &mut Arc<A> {
&mut self.assets
}
/// The default window icon Tauri should use when creating windows.
#[inline(always)]
pub fn default_window_icon(&self) -> Option<&[u8]> {
self.default_window_icon.as_deref()
}
/// The icon to use use on the system tray UI.
/// A mutable reference to the default window icon Tauri should use when creating windows.
#[inline(always)]
pub fn default_window_icon_mut(&mut self) -> &mut Option<Vec<u8>> {
&mut self.default_window_icon
}
/// The icon to use on the system tray UI.
#[inline(always)]
pub fn system_tray_icon(&self) -> Option<&Icon> {
self.system_tray_icon.as_ref()
}
/// A mutable reference to the icon to use on the system tray UI.
#[inline(always)]
pub fn system_tray_icon_mut(&mut self) -> &mut Option<Icon> {
&mut self.system_tray_icon
}
/// Package information.
#[inline(always)]
pub fn package_info(&self) -> &crate::api::PackageInfo {
&self.package_info
}
/// A mutable reference to the package information.
#[inline(always)]
pub fn package_info_mut(&mut self) -> &mut crate::api::PackageInfo {
&mut self.package_info
}
/// Create a new [`Context`] from the minimal required items.
#[inline(always)]
pub fn new(