Skip to content

Commit

Permalink
feat(core): finish mutable getters for Context (#1814)
Browse files Browse the repository at this point in the history
  • Loading branch information
chippers committed May 13, 2021
1 parent 39f8f26 commit 754c2e7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .changes/context-mutable-methods.md
@@ -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`
26 changes: 25 additions & 1 deletion core/tauri/src/lib.rs
Expand Up @@ -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(
Expand Down

0 comments on commit 754c2e7

Please sign in to comment.