Skip to content
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

[feat] Implement Debug for tauri::State #3676

Closed
mihirsamdarshi opened this issue Mar 11, 2022 · 1 comment
Closed

[feat] Implement Debug for tauri::State #3676

mihirsamdarshi opened this issue Mar 11, 2022 · 1 comment

Comments

@mihirsamdarshi
Copy link

Describe the problem

I am writing an application, and I would like to add the #[instrument] macro from the tracing crate (as well as Sentry) to some of my tauri::commands.

However in order to do that, for some of my commands which access state, I am receiving the following error, which states that tauri::State does not implement Debug

error[E0277]: `tauri::State<'_, state::InfraState>` doesn't implement `std::fmt::Debug`
   --> src/ssh/port_forward.rs:722:1
    |
722 | #[instrument]
    | ^^^^^^^^^^^^^ `tauri::State<'_, state::InfraState>` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
    |
    = help: the trait `std::fmt::Debug` is not implemented for `tauri::State<'_, state::InfraState>`
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `&tauri::State<'_, state::InfraState>`
note: required by a bound in `tracing::field::debug

Describe the solution you'd like

Implement Debug for tauri::State

Please let me know what method works the best, I was thinking that you could utilize the inner method of State

impl<T: Send + Sync + Debug + 'static> Debug for State<'_, T> {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!("tauri::State \{ {} \}", self.inner().fmt())
    }
}

Alternatives considered

No response

Additional context

No response

@JonasKruckenberg
Copy link
Member

#3677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants