Skip to main content

NodeIo

Struct NodeIo 

Source
pub struct NodeIo<'a> { /* private fields */ }
Expand description

What a node can do while it runs: report text and ask a person (in a streamed run), and keep its progress (in a checkpointed one).

Implementations§

Source§

impl<'a> NodeIo<'a>

Source

pub fn quiet(node: &'a str) -> Self

The view of node node in a plain run: its text goes nowhere, and it cannot ask. Build one to run a node yourself.

Source

pub fn streaming( node: &'a str, text: &'a (dyn Fn(&str) + Send + Sync), question: &'a (dyn Fn(Question) + Send + Sync), ) -> Self

The view of node node in a streamed run: its text goes to text, its questions to question.

Source

pub fn run_state(&self) -> &RunState

The request-scoped state of the run the node is part of: what the graph was started with, see RunState. Empty for a node run by hand.

Source

pub fn node(&self) -> &str

The node’s id.

Source

pub fn is_streaming(&self) -> bool

Whether the run is streamed: text is reported and questions asked.

Source

pub fn text(&self, text: &str)

Report text the node wrote; nothing in a plain run.

Source

pub async fn ask( &self, question: impl Into<String>, context: impl Into<String>, ) -> Result<String, NodeError>

Ask a person question about context, and wait for the answer. Fails in a plain run, where nobody can answer.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for NodeIo<'a>

§

impl<'a> !UnwindSafe for NodeIo<'a>

§

impl<'a> Forget for NodeIo<'a>

§

impl<'a> Freeze for NodeIo<'a>
where &'a str: Freeze, &'a (dyn Fn(&str) + Sync + Send): Freeze, &'a (dyn Fn(Question) + Sync + Send): Freeze, *const ArcInner<dyn Files> is !null: Freeze, PhantomData<ArcInner<dyn Files>>: Freeze, &'static str: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze, *const ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>>> is !null: Freeze, PhantomData<ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>>>>: Freeze,

§

impl<'a> Move for NodeIo<'a>

§

impl<'a> Send for NodeIo<'a>
where &'a str: Send, &'a (dyn Fn(&str) + Sync + Send): Send, &'a (dyn Fn(Question) + Sync + Send): Send, Arc<dyn Files>: Send, &'static str: Send, RawVecInner: Send, Arc<HashMap<TypeId, Arc<dyn Any + Sync + Send>>>: Send,

§

impl<'a> Sync for NodeIo<'a>
where Arc<dyn Files>: Sync, RawVecInner: Sync, Arc<HashMap<TypeId, Arc<dyn Any + Sync + Send>>>: Sync,

§

impl<'a> Unpin for NodeIo<'a>
where &'a str: Unpin, &'a (dyn Fn(&str) + Sync + Send): Unpin, &'a (dyn Fn(Question) + Sync + Send): Unpin, Arc<dyn Files>: Unpin, &'static str: Unpin, *const u8 is !null: Unpin, Arc<HashMap<TypeId, Arc<dyn Any + Sync + Send>>>: Unpin,

§

impl<'a> UnsafeUnpin for NodeIo<'a>
where &'a str: UnsafeUnpin, &'a (dyn Fn(&str) + Sync + Send): UnsafeUnpin, &'a (dyn Fn(Question) + Sync + Send): UnsafeUnpin, *const ArcInner<dyn Files> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Files>>: UnsafeUnpin, &'static str: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>>> is !null: UnsafeUnpin, PhantomData<ArcInner<HashMap<TypeId, Arc<dyn Any + Sync + Send>>>>: UnsafeUnpin,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WasmCompatSend for T
where T: Send,

Source§

impl<T> WasmCompatSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more