pub struct MultiLayerExtractor { /* private fields */ }Expand description
Multi-layer extractor for maximum reliability
This combines all four detection layers:
- Native Hooks (100%): Direct agent integration
- Session Monitor (95%): Process monitoring
- Inactivity Detector (90%): Timeout detection
- Persistent Buffer (99%): Crash recovery
§Example
ⓘ
use nexus_hooks::{HookFactory, MultiLayerExtractor};
use std::sync::Arc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let factory = HookFactory::new();
let hook = factory.create_hook("claude-code")?;
let extractor = MultiLayerExtractor::new()
.with_hook(hook)
.await?;
// Start monitoring
extractor.start().await?;
// Extract context
let context = extractor.extract().await?;
println!("Extracted: {:?}", context);
// Stop and flush
extractor.stop().await?;
Ok(())
}Implementations§
Source§impl MultiLayerExtractor
impl MultiLayerExtractor
Sourcepub async fn with_hook(self, hook: Box<dyn AgentHook>) -> Result<Self>
pub async fn with_hook(self, hook: Box<dyn AgentHook>) -> Result<Self>
Add a hook to the extractor
Sourcepub fn subscribe(&self) -> Receiver<ExtractionEvent>
pub fn subscribe(&self) -> Receiver<ExtractionEvent>
Subscribe to extraction events
Sourcepub async fn extract(&self, agent_type: &str) -> Result<SessionContext>
pub async fn extract(&self, agent_type: &str) -> Result<SessionContext>
Extract context for an agent
Sourcepub async fn stats(&self) -> ExtractionStats
pub async fn stats(&self) -> ExtractionStats
Get extraction statistics
Sourcepub async fn trigger_extraction(&self, agent_type: &str) -> Result<HookResult>
pub async fn trigger_extraction(&self, agent_type: &str) -> Result<HookResult>
Manually trigger extraction for an agent
Sourcepub async fn check_for_recovery(&self) -> Result<Vec<(String, BufferData)>>
pub async fn check_for_recovery(&self) -> Result<Vec<(String, BufferData)>>
Check for buffered data to recover
Sourcepub async fn clear_buffer(&self, agent_type: &str) -> Result<()>
pub async fn clear_buffer(&self, agent_type: &str) -> Result<()>
Clear buffer for an agent
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MultiLayerExtractor
impl !RefUnwindSafe for MultiLayerExtractor
impl Send for MultiLayerExtractor
impl Sync for MultiLayerExtractor
impl Unpin for MultiLayerExtractor
impl UnsafeUnpin for MultiLayerExtractor
impl !UnwindSafe for MultiLayerExtractor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more