Skip to main content

InterruptibleNode

Struct InterruptibleNode 

Source
pub struct InterruptibleNode<S: StateSchema, F> { /* private fields */ }
Expand description

Resume-aware node (LangGraph-style interrupt).

The wrapped closure is called twice per runtime interrupt:

  • first pass: resume is None — the node either completes normally or suspends itself by returning Err(GraphError::InterruptRequest { payload });
  • resume: after a human answers, the node is re-entered with resume = Some(decision) so the closure can continue past the suspension.

Branch on that second argument instead of re-walking expensive side effects (an API call, a DB write) that already happened on the first pass — keep any such work memoized in the state between the two passes.

Implementations§

Source§

impl<S: StateSchema, F> InterruptibleNode<S, F>
where F: Fn(&S, Option<&Value>) -> Pin<Box<dyn Future<Output = NodeResult<S>> + Send>> + Send + Sync,

Source

pub fn new(name: impl Into<String>, func: F) -> Self

Create a resume-aware node. The closure takes the current state and the injected resume decision (None on first pass, Some(decision) on resume).

Trait Implementations§

Source§

impl<S: StateSchema, F> GraphNode<S> for InterruptibleNode<S, F>
where F: Fn(&S, Option<&Value>) -> Pin<Box<dyn Future<Output = NodeResult<S>> + Send>> + Send + Sync + 'static,

Source§

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, state: &'life1 S, config: Option<NodeConfig>, ) -> Pin<Box<dyn Future<Output = Result<StateUpdate<S>, GraphError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the node Read more
Source§

fn name(&self) -> &str

Get node name

Auto Trait Implementations§

§

impl<S, F> Freeze for InterruptibleNode<S, F>
where F: Freeze, PhantomData<S>: Freeze,

§

impl<S, F> RefUnwindSafe for InterruptibleNode<S, F>

§

impl<S, F> Send for InterruptibleNode<S, F>
where F: Send, PhantomData<S>: Send,

§

impl<S, F> Sync for InterruptibleNode<S, F>
where F: Sync, PhantomData<S>: Sync,

§

impl<S, F> Unpin for InterruptibleNode<S, F>
where F: Unpin, PhantomData<S>: Unpin,

§

impl<S, F> UnsafeUnpin for InterruptibleNode<S, F>

§

impl<S, F> UnwindSafe for InterruptibleNode<S, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.