mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Reduce hook table public surface
This commit is contained in:
@@ -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::<DemoLeaf>;
|
||||
/// ```
|
||||
#[macro_export]
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user