From 7c0ee31d3854e3641cf96afb899b69dc5441cc7f Mon Sep 17 00:00:00 2001 From: Michael Mikovsky <77305074+Astatin3@users.noreply.github.com> Date: Thu, 30 Apr 2026 10:15:54 -0600 Subject: [PATCH] Reduce hook table public surface --- unshell-leaves/src/lib.rs | 3 ++- unshell-protocol/src/protocol/tree/hook.rs | 25 ++-------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/unshell-leaves/src/lib.rs b/unshell-leaves/src/lib.rs index 7545f0a..1578b2e 100644 --- a/unshell-leaves/src/lib.rs +++ b/unshell-leaves/src/lib.rs @@ -29,13 +29,14 @@ pub use unshell_protocol as protocol; /// use unshell_leaves::role_leaf; /// mod endpoint { pub struct DemoEndpoint; } /// mod tui { pub struct DemoTui; } +/// # #[cfg(not(all(feature = "leaf_endpoint", feature = "leaf_tui")))] /// role_leaf! { /// pub type DemoLeaf { /// endpoint => endpoint::DemoEndpoint, /// tui => tui::DemoTui, /// } /// } -/// # #[cfg(feature = "leaf_endpoint")] +/// # #[cfg(all(feature = "leaf_endpoint", not(feature = "leaf_tui")))] /// # let _ = core::marker::PhantomData::; /// ``` #[macro_export] diff --git a/unshell-protocol/src/protocol/tree/hook.rs b/unshell-protocol/src/protocol/tree/hook.rs index e43d713..368b4b4 100644 --- a/unshell-protocol/src/protocol/tree/hook.rs +++ b/unshell-protocol/src/protocol/tree/hook.rs @@ -365,27 +365,6 @@ impl HookTable { self.active.get(key) } - /// Returns the mutable active hook for `key`, if present. - /// - /// # Example - /// ```rust - /// use unshell::protocol::tree::{ActiveHook, HookKey, HookTable}; - /// let mut hooks = HookTable::default(); - /// let key = HookKey::new(vec!["root".into()], 1); - /// hooks.insert_active(key.clone(), ActiveHook { - /// peer_path: vec!["worker".into()], - /// procedure_id: "example.service.v1.invoke".into(), - /// local_ended: false, - /// peer_ended: false, - /// })?; - /// hooks.active_mut(&key).unwrap().peer_ended = true; - /// assert!(hooks.active(&key).unwrap().peer_ended); - /// # Ok::<(), unshell::protocol::tree::HookConflict>(()) - /// ``` - pub fn active_mut(&mut self, key: &HookKey) -> Option<&mut ActiveHook> { - self.active.get_mut(key) - } - /// Resolves an active hook from either side of the conversation. /// /// The host side addresses hooks directly by `(return_path, hook_id)`. Peer-originated @@ -447,7 +426,7 @@ impl HookTable { /// # Ok::<(), unshell::protocol::tree::HookConflict>(()) /// ``` pub fn mark_local_end(&mut self, key: &HookKey) -> bool { - let Some(active) = self.active_mut(key) else { + let Some(active) = self.active.get_mut(key) else { return false; }; active.local_ended = true; @@ -474,7 +453,7 @@ impl HookTable { /// # Ok::<(), unshell::protocol::tree::HookConflict>(()) /// ``` pub fn mark_peer_end(&mut self, key: &HookKey) -> bool { - let Some(active) = self.active_mut(key) else { + let Some(active) = self.active.get_mut(key) else { return false; }; active.peer_ended = true;