pub struct Builder<'w, 's, 'a> { /* private fields */ }Expand description
Device used for building a workflow. Simply pass a mutable borrow of this into any functions which ask for it.
Note that each scope has its own Builder, and a panic will occur if a
Builder gets used in the wrong scope. As of right now there is no known
way to trick the compiler into using a Builder in the wrong scope, but
please open an issue with a minimal reproducible example if you find a way
to make it panic.
Implementations§
Source§impl<'w, 's, 'a> Builder<'w, 's, 'a>
impl<'w, 's, 'a> Builder<'w, 's, 'a>
Sourcepub fn chain<'b, Response: 'static + Send + Sync>(
&'b mut self,
output: Output<Response>,
) -> Chain<'w, 's, 'a, 'b, Response>
pub fn chain<'b, Response: 'static + Send + Sync>( &'b mut self, output: Output<Response>, ) -> Chain<'w, 's, 'a, 'b, Response>
Begin building a chain of operations off of an output.
Sourcepub fn create_node<P: Provider>(
&mut self,
provider: P,
) -> Node<P::Request, P::Response, P::Streams>
pub fn create_node<P: Provider>( &mut self, provider: P, ) -> Node<P::Request, P::Response, P::Streams>
Create a node for a provider. This will give access to an input slot, an output slots, and a pack of stream outputs which can all be connected to other nodes.
Sourcepub fn create_map_block<T, U>(
&mut self,
f: impl FnMut(T) -> U + 'static + Send + Sync,
) -> Node<T, U, ()>
pub fn create_map_block<T, U>( &mut self, f: impl FnMut(T) -> U + 'static + Send + Sync, ) -> Node<T, U, ()>
Create a node that provides a blocking map.
Sourcepub fn create_map_async<T, Task>(
&mut self,
f: impl FnMut(T) -> Task + 'static + Send + Sync,
) -> Node<T, Task::Output, ()>
pub fn create_map_async<T, Task>( &mut self, f: impl FnMut(T) -> Task + 'static + Send + Sync, ) -> Node<T, Task::Output, ()>
Sourcepub fn create_map<M, F: AsMap<M>>(
&mut self,
f: F,
) -> Node<RequestOfMap<M, F>, ResponseOfMap<M, F>, StreamsOfMap<M, F>>where
F::MapType: Provider,
RequestOfMap<M, F>: 'static + Send + Sync,
ResponseOfMap<M, F>: 'static + Send + Sync,
StreamsOfMap<M, F>: StreamPack,
pub fn create_map<M, F: AsMap<M>>(
&mut self,
f: F,
) -> Node<RequestOfMap<M, F>, ResponseOfMap<M, F>, StreamsOfMap<M, F>>where
F::MapType: Provider,
RequestOfMap<M, F>: 'static + Send + Sync,
ResponseOfMap<M, F>: 'static + Send + Sync,
StreamsOfMap<M, F>: StreamPack,
Create a map (either a blocking map or an
async map) by providing a function that takes BlockingMap or
AsyncMap as its only argument.
Sourcepub fn create_injection_node<Request, Response, Streams>(
&mut self,
) -> Node<(Request, ServiceInstructions<Request, Response, Streams>), Response, Streams>
pub fn create_injection_node<Request, Response, Streams>( &mut self, ) -> Node<(Request, ServiceInstructions<Request, Response, Streams>), Response, Streams>
Create a node that takes in a (request, service) at runtime and then
passes the request into the service. All streams will be forwarded
and the response of the service will be the node’s output.
This allows services to be injected into workflows as input, or for a service to be chosen during runtime.
Sourcepub fn connect<T: 'static + Send + Sync>(
&mut self,
output: Output<T>,
input: InputSlot<T>,
)
pub fn connect<T: 'static + Send + Sync>( &mut self, output: Output<T>, input: InputSlot<T>, )
Connect the output of one into the input slot of another node.
Sourcepub fn create_buffer<T: 'static + Send + Sync>(
&mut self,
settings: BufferSettings,
) -> Buffer<T>
pub fn create_buffer<T: 'static + Send + Sync>( &mut self, settings: BufferSettings, ) -> Buffer<T>
Create a Buffer which can be used to store and pull data within
a scope. This is often used along with joining to synchronize multiple
branches.
Sourcepub fn create_scope<Request, Response, Streams, Settings>(
&mut self,
build: impl FnOnce(Scope<Request, Response, Streams>, &mut Builder<'_, '_, '_>) -> Settings,
) -> Node<Request, Response, Streams>where
Request: 'static + Send + Sync,
Response: 'static + Send + Sync,
Streams: StreamPack,
Settings: Into<ScopeSettings>,
pub fn create_scope<Request, Response, Streams, Settings>(
&mut self,
build: impl FnOnce(Scope<Request, Response, Streams>, &mut Builder<'_, '_, '_>) -> Settings,
) -> Node<Request, Response, Streams>where
Request: 'static + Send + Sync,
Response: 'static + Send + Sync,
Streams: StreamPack,
Settings: Into<ScopeSettings>,
Create an isolated scope within the workflow. This can be useful for racing multiple branches, creating an uninterruptible segment within your workflow, or being able to run the same multiple instances of the same sub-workflow in parallel without them interfering with each other.
A value can be sent into the scope by connecting an Output of a node
in the parent scope to the InputSlot of the node which gets returned
by this function. Each time a value is sent into the scope, it will run
through the workflow of the scope with a unique session ID. Even if
multiple values are sent in from the same session, they will each be
assigned their own unique session ID while inside of this scope.
Sourcepub fn create_io_scope<Request, Response, Settings>(
&mut self,
build: impl FnOnce(Scope<Request, Response, ()>, &mut Builder<'_, '_, '_>) -> Settings,
) -> Node<Request, Response, ()>
pub fn create_io_scope<Request, Response, Settings>( &mut self, build: impl FnOnce(Scope<Request, Response, ()>, &mut Builder<'_, '_, '_>) -> Settings, ) -> Node<Request, Response, ()>
Alternative to Self::create_scope for pure input/output scopes (i.e.
there are no output streams). Using this signature should allow the
compiler to infer all the generic arguments when there are no streams.
Sourcepub fn create_fork_clone<T>(&mut self) -> (InputSlot<T>, ForkCloneOutput<T>)
pub fn create_fork_clone<T>(&mut self) -> (InputSlot<T>, ForkCloneOutput<T>)
Create an operation that clones its inputs and sends them off to any number of targets.
Sourcepub fn create_unzip<T>(&mut self) -> (InputSlot<T>, T::Unzipped)
pub fn create_unzip<T>(&mut self) -> (InputSlot<T>, T::Unzipped)
Create an operation that unzips its inputs and sends each element off to a different output.
Sourcepub fn create_fork_result<T, E>(
&mut self,
) -> (InputSlot<Result<T, E>>, ForkResultOutput<T, E>)
pub fn create_fork_result<T, E>( &mut self, ) -> (InputSlot<Result<T, E>>, ForkResultOutput<T, E>)
Sourcepub fn create_fork_option<T>(
&mut self,
) -> (InputSlot<Option<T>>, ForkOptionOutput<T>)
pub fn create_fork_option<T>( &mut self, ) -> (InputSlot<Option<T>>, ForkOptionOutput<T>)
Sourcepub fn join<'b, B: Joinable>(
&'b mut self,
buffers: B,
) -> Chain<'w, 's, 'a, 'b, B::Item>
pub fn join<'b, B: Joinable>( &'b mut self, buffers: B, ) -> Chain<'w, 's, 'a, 'b, B::Item>
Alternative way of calling Joinable::join
Sourcepub fn try_join<'b, J: Joined>(
&'b mut self,
buffers: &BufferMap,
) -> Result<Chain<'w, 's, 'a, 'b, J>, IncompatibleLayout>
pub fn try_join<'b, J: Joined>( &'b mut self, buffers: &BufferMap, ) -> Result<Chain<'w, 's, 'a, 'b, J>, IncompatibleLayout>
Try joining a map of buffers into a single value.
Sourcepub fn listen<'b, B: Accessible>(
&'b mut self,
buffers: B,
) -> Chain<'w, 's, 'a, 'b, B::Keys>
pub fn listen<'b, B: Accessible>( &'b mut self, buffers: B, ) -> Chain<'w, 's, 'a, 'b, B::Keys>
Alternative way of calling Accessible::listen.
Sourcepub fn try_listen<'b, Keys: Accessor>(
&'b mut self,
buffers: &BufferMap,
) -> Result<Chain<'w, 's, 'a, 'b, Keys>, IncompatibleLayout>
pub fn try_listen<'b, Keys: Accessor>( &'b mut self, buffers: &BufferMap, ) -> Result<Chain<'w, 's, 'a, 'b, Keys>, IncompatibleLayout>
Try listening to a map of buffers.
Sourcepub fn create_buffer_access<T, B: Bufferable>(
&mut self,
buffers: B,
) -> Node<T, (T, BufferKeys<B>)>
pub fn create_buffer_access<T, B: Bufferable>( &mut self, buffers: B, ) -> Node<T, (T, BufferKeys<B>)>
Create a node that combines its inputs with access to some buffers. You
must specify one ore more buffers to access. FOr multiple buffers,
combine then into a tuple or an Iterator. Tuples of buffers can be
nested inside each other.
Other outputs can also be passed in as buffers. These outputs will be transformed into a buffer with default buffer settings.
Sourcepub fn try_create_buffer_access<T, Keys: Accessor>(
&mut self,
buffers: &BufferMap,
) -> Result<Node<T, (T, Keys)>, IncompatibleLayout>
pub fn try_create_buffer_access<T, Keys: Accessor>( &mut self, buffers: &BufferMap, ) -> Result<Node<T, (T, Keys)>, IncompatibleLayout>
Try to create access to some buffers. Same as Self::create_buffer_access
except it will return an error if the buffers in the BufferMap are not
compatible with the keys that are being asked for.
Sourcepub fn create_collect<T, const N: usize>(
&mut self,
min: usize,
max: Option<usize>,
) -> Node<T, SmallVec<[T; N]>>
pub fn create_collect<T, const N: usize>( &mut self, min: usize, max: Option<usize>, ) -> Node<T, SmallVec<[T; N]>>
Collect incoming workflow threads into a container.
If max is specified, the collection will always be sent out once it
reaches that maximum value.
If min is greater than 0 then the collection will not be sent out unless
it is equal to or greater than that value. Note that this means the
collect operation could force the workflow into cancelling if it cannot
reach the minimum number of elements. A min of 0 means that if an
upstream thread is disposed and the collect node is no longer reachable
then it will fire off with an empty collection.
If the min limit is satisfied and there are no remaining workflow
threads that can reach this collect operation, then the collection will
be sent out with however many elements it happens to have collected.
Sourcepub fn create_collect_all<T, const N: usize>(
&mut self,
) -> Node<T, SmallVec<[T; N]>>
pub fn create_collect_all<T, const N: usize>( &mut self, ) -> Node<T, SmallVec<[T; N]>>
Collect all workflow threads that are moving towards this node.
Sourcepub fn create_collect_n<T, const N: usize>(
&mut self,
n: usize,
) -> Node<T, SmallVec<[T; N]>>
pub fn create_collect_n<T, const N: usize>( &mut self, n: usize, ) -> Node<T, SmallVec<[T; N]>>
Collect an exact number of threads that are moving towards this node.
Sourcepub fn create_split<T>(&mut self) -> (InputSlot<T>, SplitOutputs<T>)
pub fn create_split<T>(&mut self) -> (InputSlot<T>, SplitOutputs<T>)
Create a new split operation in the workflow. The InputSlot can take
in values that you want to split, and SplitOutputs::build will let
you build connections to the split value.
Sourcepub fn create_cancel<T>(&mut self) -> InputSlot<T>
pub fn create_cancel<T>(&mut self) -> InputSlot<T>
Create an input slot that will cancel the current scope when it gets
triggered. This can be used on types that implement ToString.
If you need to cancel for a type that does not implement ToString
then convert it to a trigger () and then connect it to
Self::create_quiet_cancel.
Sourcepub fn create_quiet_cancel(&mut self) -> InputSlot<()>
pub fn create_quiet_cancel(&mut self) -> InputSlot<()>
Create an input slot that will cancel that current scope when it gets triggered.
If you want the cancellation message to include information about the
input value that triggered it, use Self::create_cancel.
Sourcepub fn on_cleanup<B, Settings>(
&mut self,
from_buffers: B,
build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings,
)
pub fn on_cleanup<B, Settings>( &mut self, from_buffers: B, build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings, )
This method allows you to define a cleanup workflow that branches off of this scope that will activate during the scope’s cleanup phase. The input to the cleanup workflow will be a key to access to one or more buffers from the parent scope.
Each different cleanup workflow that you define using this function will be given its own unique session ID when it gets run. You can define any number of cleanup workflows.
The parent scope will only finish its cleanup phase after all cleanup workflows for the scope have finished, either by terminating or by being cancelled themselves.
Cleanup workflows that you define with this function will always be run
no matter how the scope finished. If you want a cleanup workflow that
only runs when the scope is cancelled, use Self::on_cancel. If you
want a cleanup workflow that only runs when the scope terminates
successfully, then use Self::on_terminate. For easier runtime
flexibility you can also use Self::on_cleanup_if.
Sourcepub fn on_cancel<B, Settings>(
&mut self,
from_buffers: B,
build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings,
)
pub fn on_cancel<B, Settings>( &mut self, from_buffers: B, build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings, )
Define a cleanup workflow that only gets run if the scope was cancelled.
When the scope gets dropped before it terminates (i.e. the parent scope finished while this scope was active, and this scope is interruptible) that also counts as cancelled.
A scope which is set to be uninterruptible will still experience a cancellation if its terminal node becomes unreachable.
If you want a cleanup workflow that only runs when the scope terminates
successfully then use Self::on_terminate. If you want a cleanup
workflow that always runs when the scope is finished, then use
Self::on_cleanup.
Sourcepub fn on_terminate<B, Settings>(
&mut self,
from_buffers: B,
build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings,
)
pub fn on_terminate<B, Settings>( &mut self, from_buffers: B, build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings, )
Define a cleanup workflow that only gets run if the scope was successfully terminated. That means an input reached its terminal node, and now the scope is cleaning up.
If you want a cleanup workflow that only runs when the scope is cancelled
then use Self::on_cancel. If you want a cleanup workflow that always
runs when then scope is finished, then use Self::on_cleanup.
Sourcepub fn on_cleanup_if<B, Settings>(
&mut self,
conditions: CleanupWorkflowConditions,
from_buffers: B,
build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings,
)
pub fn on_cleanup_if<B, Settings>( &mut self, conditions: CleanupWorkflowConditions, from_buffers: B, build: impl FnOnce(Scope<BufferKeys<B>, (), ()>, &mut Builder<'_, '_, '_>) -> Settings, )
Define a sub-workflow that will be run when this workflow is being cleaned up if the conditions are met. A workflow enters the cleanup stage when its terminal node is reached or if it gets cancelled.
Sourcepub fn create_trim<T>(
&mut self,
branches: impl IntoIterator<Item = TrimBranch>,
) -> Node<T, T>
pub fn create_trim<T>( &mut self, branches: impl IntoIterator<Item = TrimBranch>, ) -> Node<T, T>
Create a node that trims (cancels) other nodes in the workflow when it gets activated. The input into the node will be passed along as output after the trimming is confirmed to be completed.
Sourcepub fn create_gate<T, B>(&mut self, buffers: B) -> Node<GateRequest<T>, T>
pub fn create_gate<T, B>(&mut self, buffers: B) -> Node<GateRequest<T>, T>
Create a gate node that can open and close the gates on one or more
buffers. Feed a GateRequest into the node and all the associated
buffers will be opened or closed based on the action inside the request.
The data inside the request will be passed along as output once the gate action is finished.
See Gate to understand what happens when a gate is opened or closed.
Sourcepub fn create_gate_action<T, B>(
&mut self,
action: Gate,
buffers: B,
) -> Node<T, T>
pub fn create_gate_action<T, B>( &mut self, action: Gate, buffers: B, ) -> Node<T, T>
Create a gate node that always opens or always closes the gates on one or more buffers.
The data sent into the node will be passed back out as input, unchanged.
See Gate to understand what happens when a gate is opened or closed.
Sourcepub fn create_gate_open<B, T>(&mut self, buffers: B) -> Node<T, T>
pub fn create_gate_open<B, T>(&mut self, buffers: B) -> Node<T, T>
Create a gate node that always opens the gates on one or more buffers.
See Gate to understand what happens when a gate is opened or closed.
Sourcepub fn create_gate_close<T, B>(&mut self, buffers: B) -> Node<T, T>
pub fn create_gate_close<T, B>(&mut self, buffers: B) -> Node<T, T>
Create a gate node that always closes the gates on one or more buffers.
See Gate to understand what happens when a gate is opened or closed.
pub fn context(&self) -> BuilderScopeContext
Auto Trait Implementations§
impl<'w, 's, 'a> Freeze for Builder<'w, 's, 'a>
impl<'w, 's, 'a> RefUnwindSafe for Builder<'w, 's, 'a>
impl<'w, 's, 'a> Send for Builder<'w, 's, 'a>
impl<'w, 's, 'a> Sync for Builder<'w, 's, 'a>
impl<'w, 's, 'a> Unpin for Builder<'w, 's, 'a>
impl<'w, 's, 'a> !UnwindSafe for Builder<'w, 's, 'a>
Blanket Implementations§
Source§impl<Source> AccessAs for Source
impl<Source> AccessAs for Source
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request