@@ -72,7 +72,7 @@ pub use {
7272 dpi:: { LogicalPosition , LogicalSize , PhysicalPosition , PhysicalSize , Pixel , Position , Size } ,
7373 WindowEvent ,
7474 } ,
75- MenuId , Params ,
75+ Icon , MenuId , Params ,
7676 } ,
7777 self :: state:: { State , StateManager } ,
7878 self :: window:: { Monitor , Window } ,
@@ -128,25 +128,61 @@ macro_rules! tauri_build_context {
128128/// This is the output of the `tauri::generate_context!` macro, and is not considered part of the stable API.
129129/// Unless you know what you are doing and are prepared for this type to have breaking changes, do not create it yourself.
130130pub struct Context < A : Assets > {
131+ pub ( crate ) config : Config ,
132+ pub ( crate ) assets : Arc < A > ,
133+ pub ( crate ) default_window_icon : Option < Vec < u8 > > ,
134+ pub ( crate ) system_tray_icon : Option < Icon > ,
135+ pub ( crate ) package_info : crate :: api:: PackageInfo ,
136+ }
137+
138+ impl < A : Assets > Context < A > {
131139 /// The config the application was prepared with.
132- pub config : Config ,
140+ #[ inline( always) ]
141+ pub fn config ( & self ) -> & Config {
142+ & self . config
143+ }
133144
134145 /// The assets to be served directly by Tauri.
135- pub assets : Arc < A > ,
146+ #[ inline( always) ]
147+ pub fn assets ( & self ) -> Arc < A > {
148+ self . assets . clone ( )
149+ }
136150
137151 /// The default window icon Tauri should use when creating windows.
138- pub default_window_icon : Option < Vec < u8 > > ,
139-
140- /// The icon to use use on the system tray UI.
141- #[ cfg( target_os = "linux" ) ]
142- pub system_tray_icon : Option < std:: path:: PathBuf > ,
152+ #[ inline( always) ]
153+ pub fn default_window_icon ( & self ) -> Option < & [ u8 ] > {
154+ self . default_window_icon . as_deref ( )
155+ }
143156
144157 /// The icon to use use on the system tray UI.
145- #[ cfg( not( target_os = "linux" ) ) ]
146- pub system_tray_icon : Option < Vec < u8 > > ,
158+ #[ inline( always) ]
159+ pub fn system_tray_icon ( & self ) -> Option < & Icon > {
160+ self . system_tray_icon . as_ref ( )
161+ }
147162
148163 /// Package information.
149- pub package_info : crate :: api:: PackageInfo ,
164+ #[ inline( always) ]
165+ pub fn package_info ( & self ) -> & crate :: api:: PackageInfo {
166+ & self . package_info
167+ }
168+
169+ /// Create a new [`Context`] from the minimal required items.
170+ #[ inline( always) ]
171+ pub fn new (
172+ config : Config ,
173+ assets : Arc < A > ,
174+ default_window_icon : Option < Vec < u8 > > ,
175+ system_tray_icon : Option < Icon > ,
176+ package_info : crate :: api:: PackageInfo ,
177+ ) -> Self {
178+ Self {
179+ config,
180+ assets,
181+ default_window_icon,
182+ system_tray_icon,
183+ package_info,
184+ }
185+ }
150186}
151187
152188// TODO: expand these docs
0 commit comments