From 33f9388e128ff47fe0fd618404e663412b2c8f32 Mon Sep 17 00:00:00 2001 From: Ben Dean-Kawamura Date: Fri, 5 Jun 2026 09:29:38 -0400 Subject: [PATCH] tabs/tracing-support: Refactorings for `uniffi_parse_rs` I'm working on a new UniFFI parser (https://github.com/mozilla/uniffi-rs/pull/2841) and it currently has a couple extra requirements for types used in exported functions: * The types are publicly available from other crates. * The name matches the one used in the `custom_type!` macro. I could maybe rework the parser to avoid these requirements, but the changes feel like improvements to me. Please push back if you don't think so. --- components/support/tracing/src/layer.rs | 8 ++++---- components/support/tracing/src/lib.rs | 6 +++--- components/tabs/src/lib.rs | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/components/support/tracing/src/layer.rs b/components/support/tracing/src/layer.rs index 144e49819d..6755af58de 100644 --- a/components/support/tracing/src/layer.rs +++ b/components/support/tracing/src/layer.rs @@ -14,7 +14,7 @@ use tracing_subscriber::{ Layer, }; -use crate::{EventSink, Level}; +use crate::{EventSink, TracingLevel}; use tracing::field::{Field, Visit}; static SINKS: RwLock> = const_rwlock(Vec::new()); @@ -52,13 +52,13 @@ pub struct EventSinkSpecification { pub targets: Vec, // Send events have a `min_level` or above. #[uniffi(default)] - pub min_level: Option, + pub min_level: Option, } #[derive(uniffi::Record, Debug)] pub struct EventTarget { pub target: String, - pub level: Level, + pub level: TracingLevel, } #[uniffi::export] @@ -124,7 +124,7 @@ fn find_sinks_for_event(event: &tracing::Event<'_>) -> Vec> { Some(index) => &target[..index], None => target, }; - let level = Level::from(*event.metadata().level()); + let level = TracingLevel::from(*event.metadata().level()); // This requires a iterating through the entire SINKS vec, which could have performance impacts // if we have many sinks registered. In practice, there should only be a handful of these so diff --git a/components/support/tracing/src/lib.rs b/components/support/tracing/src/lib.rs index 3fe52130e3..cebb0838fc 100644 --- a/components/support/tracing/src/lib.rs +++ b/components/support/tracing/src/lib.rs @@ -12,8 +12,8 @@ pub use filters::{ }; pub use layer::{ - register_event_sink, simple_event_layer, unregister_event_sink, EventSinkId, - EventSinkSpecification, EventTarget, + register_event_sink, register_event_sink_box, simple_event_layer, unregister_event_sink, + EventSinkId, EventSinkSpecification, EventTarget, }; // Re-export tracing so that our dependencies can use it. pub use tracing; @@ -152,7 +152,7 @@ pub struct TracingEvent { pub target: String, pub name: String, pub message: String, - pub fields: serde_json::Value, + pub fields: TracingJsonValue, } #[uniffi::export(callback_interface)] diff --git a/components/tabs/src/lib.rs b/components/tabs/src/lib.rs index 1038c570cb..84477b538a 100644 --- a/components/tabs/src/lib.rs +++ b/components/tabs/src/lib.rs @@ -30,7 +30,9 @@ uniffi::custom_type!(TabsGuid, String, { lower: |obj| obj.into(), }); -pub use crate::storage::{ClientRemoteTabs, LocalTabsInfo, RemoteTabRecord, TabsDeviceType}; +pub use crate::storage::{ + ClientRemoteTabs, LocalTabsInfo, RemoteTabRecord, TabGroup, TabsDeviceType, Window, WindowType, +}; pub use crate::store::{RemoteCommandStore, TabsStore}; pub use error::{ApiResult, Error, Result, TabsApiError}; use sync15::DeviceType;