Refactor the imp/gui bondary to use real traits #18

Merged
liamwarfield merged 8 commits from gui-platform-boundary-refactor into main 2026-02-18 04:53:41 +00:00

8 Commits

Author SHA1 Message Date
liamwarfield 5f3466546e Add some Trait doc comments
Build Mumble Web 2 / windows_build (push) Successful in 2m25s
Build Mumble Web 2 / linux_build (push) Successful in 1m18s
Build Mumble Web 2 / android_build (push) Successful in 5m47s
Added comments to Audio(System|Player)Interface traits.
2026-02-17 21:28:05 -07:00
liamwarfield 8170383278 Remove connection::* import. 2026-02-17 21:28:05 -07:00
sam 2e86f68a3c some more review changes 2026-02-17 21:28:05 -07:00
sam 35b2a06e64 some ideas including stub 2026-02-17 21:28:05 -07:00
sam 09985e6031 move audio stuff into trait 2026-02-17 21:28:01 -07:00
sam 056a673bc0 all platform traits implemented & dumb async runtime imports 2026-02-17 21:26:03 -07:00
sam 411d923c2a wip improved trait shit 2026-02-17 21:26:03 -07:00
liamwarfield ff14f577fe Add Platform trait.
I did some more thinking about the whole trait/boundary stuff and reallized that we don't need the GUI to handle the generic-ness of a trait object since only 1 platform will ever be used in a binary. What do you think of the following:

1. Define a platform trait
2. Each platform defines a zero-sized struct implementing the trait (ex `WebPlatform`).
3. Create an ifdef'd type alias on those structs:

```
     // gui/src/platform/mod.rs
     #[cfg(feature = "web")]
     pub type CurrentPlatform = web::WebPlatform;
     #[cfg(feature = "desktop")]
     pub type CurrentPlatform = desktop::DesktopPlatform;
     #[cfg(feature = "mobile")]
     pub type CurrentPlatform = mobile::MobilePlatform;
```

4. Add a compile time assertion that `CurrentPlatform` implements `Platform`.

Pros:

- We don't end up working around async trait objects
- We define what functions are needed for a platform
- We save a little on binary size by avoiding a fully generic solution.

Cons:

- The trait does not really do much other than being a collection of functions.
- In some ways it seems like what we're currently doing but with extra steps.
2026-02-17 21:26:03 -07:00