pub enum HookAction {
Continue(Box<HookContext>),
Skip(Value),
Abort {
reason: String,
},
Replace(Value),
}Expand description
What the hook wants the runtime to do after execution.
§Pre-hooks (can modify/abort)
Continue— pass (possibly modified) context downstreamSkip— skip the operation, return the given value as resultAbort— abort the operation with an error
§Post-hooks (observe/replace)
Continue— pass context to next post-hookReplace— replace the result payload, continue chain
§Intentional omission
Default is NOT implemented. Continue(HookContext::empty()) would
destroy the original context silently. Handlers must return explicitly.
Variants§
Continue(Box<HookContext>)
Continue with (possibly modified) context.
Skip(Value)
Skip the operation entirely (pre-hooks only).
The Value is returned as the operation’s result.
Abort
Abort the operation with an error (pre-hooks only).
Replace(Value)
Replace the result with a different value (post-hooks only). In a post-hook chain, the replaced value becomes the new payload for subsequent hooks.
Implementations§
Source§impl HookAction
impl HookAction
Sourcepub fn is_continue(&self) -> bool
pub fn is_continue(&self) -> bool
Returns true if this is a Continue variant.
Sourcepub fn is_replace(&self) -> bool
pub fn is_replace(&self) -> bool
Returns true if this is a Replace variant.
Trait Implementations§
Source§impl Clone for HookAction
impl Clone for HookAction
Source§fn clone(&self) -> HookAction
fn clone(&self) -> HookAction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for HookAction
impl Debug for HookAction
Source§impl<'de> Deserialize<'de> for HookAction
impl<'de> Deserialize<'de> for HookAction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for HookAction
impl RefUnwindSafe for HookAction
impl Send for HookAction
impl Sync for HookAction
impl Unpin for HookAction
impl UnsafeUnpin for HookAction
impl UnwindSafe for HookAction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more