Remove the current top scope if it matches `uuid`. # Parameters - `uuid`: UUID of the scope expected to be at the top of the stack. # Returns A [`Result`] containing the removed [`ScopeHandle`]. # Errors Returns [`FlowError::InvalidArgument`] when the scope exists but is not the current top of the stack or when the caller attempts to remove the implicit root scope. Returns [`FlowError::NotFound
(&mut self, uuid: &Uuid)
| 123 | /// implicit root scope. Returns [`FlowError::NotFound`] when the UUID is |
| 124 | /// not present on the stack. |
| 125 | pub fn remove(&mut self, uuid: &Uuid) -> Result<ScopeHandle> { |
| 126 | let top = self |
| 127 | .stack |
| 128 | .last() |
| 129 | .expect("scope stack should never be empty"); |
| 130 | if top.uuid == *uuid { |
| 131 | if self.stack.len() == 1 { |
| 132 | return Err(FlowError::InvalidArgument( |
| 133 | "root scope cannot be removed".into(), |
| 134 | )); |
| 135 | } |
| 136 | self.scope_registries.remove(uuid); |
| 137 | return Ok(self |
| 138 | .stack |
| 139 | .pop() |
| 140 | .expect("scope stack should contain a removable top scope")); |
| 141 | } |
| 142 | |
| 143 | if self.stack.iter().any(|handle| handle.uuid == *uuid) { |
| 144 | return Err(FlowError::InvalidArgument( |
| 145 | "scope handle is not at the top of the stack".into(), |
| 146 | )); |
| 147 | } |
| 148 | |
| 149 | Err(FlowError::NotFound("scope handle not found".into())) |
| 150 | } |
| 151 | |
| 152 | /// Get or create the scope-local registries for an active scope. |
| 153 | /// |
no test coverage detected