-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: reduce Debug format size for binary buffers #13809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7f49812
edb1585
7fcff4e
0ecd36e
5093c65
514eaf0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "tauri": patch:enhance | ||
| "tauri-utils": patch:enhance | ||
| --- | ||
|
|
||
| Reduced `Debug` format size for binary buffers. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -397,12 +397,32 @@ pub struct Context<R: Runtime> { | |
| pub(crate) plugin_global_api_scripts: Option<&'static [&'static str]>, | ||
| } | ||
|
|
||
| /// Temporary struct that overrides the Debug formatting for the `app_icon` field. | ||
| /// | ||
| /// It reduces the output size compared to the default, as that would format the binary | ||
| /// data as a slice of numbers `[65, 66, 67]`. This instead shows the length of the Vec. | ||
| /// | ||
| /// For example: `Some([u8; 493])` | ||
| pub(crate) struct DebugAppIcon<'a>(&'a Option<Vec<u8>>); | ||
|
|
||
| impl std::fmt::Debug for DebugAppIcon<'_> { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| match self.0 { | ||
| Option::None => f.write_str("None"), | ||
| Option::Some(icon) => f | ||
| .debug_tuple("Some") | ||
| .field(&format_args!("[u8; {}]", icon.len())) | ||
| .finish(), | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl<R: Runtime> fmt::Debug for Context<R> { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| let mut d = f.debug_struct("Context"); | ||
| d.field("config", &self.config) | ||
| .field("default_window_icon", &self.default_window_icon) | ||
| .field("app_icon", &self.app_icon) | ||
| .field("app_icon", &DebugAppIcon(&self.app_icon)) | ||
| .field("package_info", &self.package_info) | ||
| .field("pattern", &self.pattern) | ||
| .field("plugin_global_api_scripts", &self.plugin_global_api_scripts); | ||
|
Comment on lines
423
to
428
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sidenote: these are missing several fields that exist on the struct. |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,6 @@ use tauri_utils::{ | |
| config::{Csp, CspDirectiveSources}, | ||
| }; | ||
|
|
||
| use crate::resources::ResourceTable; | ||
| use crate::{ | ||
| app::{ | ||
| AppHandle, ChannelInterceptor, GlobalWebviewEventListener, GlobalWindowEventListener, | ||
|
|
@@ -27,8 +26,9 @@ use crate::{ | |
| event::{EmitArgs, Event, EventId, EventTarget, Listeners}, | ||
| ipc::{Invoke, InvokeHandler, RuntimeAuthority}, | ||
| plugin::PluginStore, | ||
| resources::ResourceTable, | ||
| utils::{config::Config, PackageInfo}, | ||
| Assets, Context, EventName, Pattern, Runtime, StateManager, Webview, Window, | ||
| Assets, Context, DebugAppIcon, EventName, Pattern, Runtime, StateManager, Webview, Window, | ||
| }; | ||
|
|
||
| #[cfg(desktop)] | ||
|
|
@@ -233,7 +233,7 @@ impl<R: Runtime> fmt::Debug for AppManager<R> { | |
| .field("plugins", &self.plugins) | ||
| .field("state", &self.state) | ||
| .field("config", &self.config) | ||
| .field("app_icon", &self.app_icon) | ||
| .field("app_icon", &DebugAppIcon(&self.app_icon)) | ||
| .field("package_info", &self.package_info) | ||
| .field("pattern", &self.pattern); | ||
|
Comment on lines
233
to
238
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Likewise missing fields. |
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't 100% sure on this one. Because it seems only macos uses this
app_icon.On Linux it was always None for me.