@@ -111,7 +111,7 @@ pub struct Context<A: Assets> {
111
111
}
112
112
113
113
/// Types associated with the running Tauri application.
114
- pub trait Params : sealed:: ParamsPrivate < Self > {
114
+ pub trait Params : sealed:: ParamsBase {
115
115
/// The event type used to create and listen to events.
116
116
type Event : Tag ;
117
117
@@ -126,7 +126,9 @@ pub trait Params: sealed::ParamsPrivate<Self> {
126
126
}
127
127
128
128
/// Manages a running application.
129
- pub trait Manager < M : Params > : sealed:: ManagerPrivate < M > {
129
+ ///
130
+ /// TODO: expand these docs
131
+ pub trait Manager < M : Params > : sealed:: ManagerBase < M > {
130
132
/// The [`Config`] the manager was created with.
131
133
fn config ( & self ) -> & Config {
132
134
self . manager ( ) . config ( )
@@ -202,126 +204,27 @@ pub trait Manager<M: Params>: sealed::ManagerPrivate<M> {
202
204
/// Prevent implementation details from leaking out of the [`Manager`] and [`Params`] traits.
203
205
pub ( crate ) mod sealed {
204
206
use super :: Params ;
205
- use crate :: runtime:: Runtime ;
206
- use crate :: {
207
- api:: { config:: Config , PackageInfo } ,
208
- event:: { Event , EventHandler } ,
209
- hooks:: { InvokeMessage , PageLoadPayload } ,
210
- runtime:: window:: { DetachedWindow , PendingWindow } ,
211
- Window ,
212
- } ;
213
- use serde:: Serialize ;
214
- use std:: collections:: { HashMap , HashSet } ;
215
- use uuid:: Uuid ;
216
-
217
- /// private manager api
218
- pub trait ParamsPrivate < M : Params > : Clone + Send + Sized + ' static {
219
- /// Pass messages not handled by modules or plugins to the running application
220
- fn run_invoke_handler ( & self , message : InvokeMessage < M > ) ;
221
-
222
- /// Ran once for every window when the page is loaded.
223
- fn run_on_page_load ( & self , window : Window < M > , payload : PageLoadPayload ) ;
224
-
225
- /// Pass a message to be handled by a plugin that expects the command.
226
- fn extend_api ( & self , command : String , message : InvokeMessage < M > ) ;
227
-
228
- /// Initialize all the plugins attached to the [`Manager`].
229
- fn initialize_plugins ( & self ) -> crate :: Result < ( ) > ;
230
-
231
- /// Prepare a [`PendingWindow`] to be created by the [`Runtime`].
232
- ///
233
- /// The passed labels should represent either all the windows in the manager. If the application
234
- /// has not yet been started, the passed labels should represent all windows that will be
235
- /// created before starting.
236
- fn prepare_window (
237
- & self ,
238
- pending : PendingWindow < M > ,
239
- labels : & [ M :: Label ] ,
240
- ) -> crate :: Result < PendingWindow < M > > ;
241
-
242
- /// Attach a detached window to the manager.
243
- fn attach_window ( & self , window : DetachedWindow < M > ) -> Window < M > ;
244
-
245
- /// Emit an event to javascript windows that pass the predicate.
246
- fn emit_filter_internal < S : Serialize + Clone , F : Fn ( & Window < Self > ) -> bool > (
247
- & self ,
248
- event : String ,
249
- payload : Option < S > ,
250
- filter : F ,
251
- ) -> crate :: Result < ( ) > ;
252
-
253
- /// Emit an event to javascript windows that pass the predicate.
254
- fn emit_filter < S : Serialize + Clone , F : Fn ( & Window < M > ) -> bool > (
255
- & self ,
256
- event : M :: Event ,
257
- payload : Option < S > ,
258
- predicate : F ,
259
- ) -> crate :: Result < ( ) > ;
260
-
261
- /// All current window labels existing.
262
- fn labels ( & self ) -> HashSet < M :: Label > ;
263
-
264
- /// The configuration the [`Manager`] was built with.
265
- fn config ( & self ) -> & Config ;
266
-
267
- /// App package information.
268
- fn package_info ( & self ) -> & PackageInfo ;
269
-
270
- /// Remove the specified event handler.
271
- fn unlisten ( & self , handler_id : EventHandler ) ;
272
-
273
- /// Trigger an event.
274
- fn trigger ( & self , event : M :: Event , window : Option < M :: Label > , data : Option < String > ) ;
275
-
276
- /// Set up a listener to an event.
277
- fn listen < F : Fn ( Event ) + Send + ' static > (
278
- & self ,
279
- event : M :: Event ,
280
- window : Option < M :: Label > ,
281
- handler : F ,
282
- ) -> EventHandler ;
283
-
284
- /// Set up a listener to and event that is automatically removed after called once.
285
- fn once < F : Fn ( Event ) + Send + ' static > (
286
- & self ,
287
- event : M :: Event ,
288
- window : Option < M :: Label > ,
289
- handler : F ,
290
- ) ;
291
-
292
- fn event_listeners_object_name ( & self ) -> String ;
293
- fn event_queue_object_name ( & self ) -> String ;
294
- fn event_emit_function_name ( & self ) -> String ;
295
-
296
- /// Generate a random salt and store it in the manager
297
- fn generate_salt ( & self ) -> Uuid ;
298
-
299
- /// Verify that the passed salt is a valid salt in the manager.
300
- fn verify_salt ( & self , salt : String ) -> bool ;
301
-
302
- /// Get a single managed window.
303
- fn get_window ( & self , label : & M :: Label ) -> Option < Window < M > > ;
304
-
305
- /// Get all managed windows.
306
- fn windows ( & self ) -> HashMap < M :: Label , Window < M > > ;
307
- }
207
+ use crate :: runtime:: { manager:: WindowManager , Runtime } ;
208
+
209
+ /// No downstream implementations of [`Params`].
210
+ pub trait ParamsBase : ' static { }
308
211
309
- /// Represents either a running [`Runtime`] or a dispatcher to it.
310
- pub enum RuntimeOrDispatch < ' m , M : Params > {
212
+ /// A running [`Runtime`] or a dispatcher to it.
213
+ pub enum RuntimeOrDispatch < ' r , P : Params > {
311
214
/// Mutable reference to the running [`Runtime`].
312
- Runtime ( & ' m mut M :: Runtime ) ,
215
+ Runtime ( & ' r mut P :: Runtime ) ,
313
216
314
217
/// A dispatcher to the running [`Runtime`].
315
- Dispatch ( <M :: Runtime as Runtime >:: Dispatcher ) ,
218
+ Dispatch ( <P :: Runtime as Runtime >:: Dispatcher ) ,
316
219
}
317
220
318
- /// Represents a managed handle to the application runner .
319
- pub trait ManagerPrivate < M : Params > {
221
+ /// Managed handle to the application runtime .
222
+ pub trait ManagerBase < P : Params > {
320
223
/// The manager behind the [`Managed`] item.
321
- fn manager ( & self ) -> & M ;
224
+ fn manager ( & self ) -> & WindowManager < P > ;
322
225
323
226
/// The runtime or runtime dispatcher of the [`Managed`] item.
324
- fn runtime ( & mut self ) -> RuntimeOrDispatch < ' _ , M > ;
227
+ fn runtime ( & mut self ) -> RuntimeOrDispatch < ' _ , P > ;
325
228
}
326
229
}
327
230
0 commit comments