From 457f8f446743f8b89b64e88d3244be759e7b7af2 Mon Sep 17 00:00:00 2001 From: Bayley Foster Date: Mon, 5 Jan 2026 19:27:00 +1030 Subject: [PATCH] plugin: export `TypedPluginGuard` and `TypedPluginHandle` (#7780) We have made this patch internally on our fork as we use `TypedPluginGuard` and `TypedPluginHandle` internally * [x] I have followed the instructions in the PR template --- crates/egui/src/lib.rs | 2 +- crates/egui/src/plugin.rs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index 4f310ba8f..bc90f0cf9 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -413,7 +413,7 @@ pub mod os; mod painter; mod pass_state; pub(crate) mod placer; -mod plugin; +pub mod plugin; pub mod response; mod sense; pub mod style; diff --git a/crates/egui/src/plugin.rs b/crates/egui/src/plugin.rs index 3967e737d..d480cc770 100644 --- a/crates/egui/src/plugin.rs +++ b/crates/egui/src/plugin.rs @@ -55,6 +55,9 @@ pub(crate) struct PluginHandle { plugin: Box, } +/// A typed handle to a registered [`Plugin`]. +/// +/// Use [`Self::lock`] to access the plugin. pub struct TypedPluginHandle { handle: Arc>, _type: std::marker::PhantomData

, @@ -68,6 +71,9 @@ impl TypedPluginHandle

{ } } + /// Lock the plugin for access. + /// + /// Returns a guard that dereferences to the plugin. pub fn lock(&self) -> TypedPluginGuard<'_, P> { TypedPluginGuard { guard: self.handle.lock(), @@ -76,6 +82,7 @@ impl TypedPluginHandle

{ } } +/// A guard that provides access to a [`Plugin`]. pub struct TypedPluginGuard<'a, P: Plugin> { guard: MutexGuard<'a, PluginHandle>, _type: std::marker::PhantomData

,