pub trait SimpleFlowNode {
type Request: Serialize + DeserializeOwned;
// Required methods
fn imports(ctx: &mut ImportCtx<'_>);
fn process_request(
request: Self::Request,
ctx: &mut NodeCtx<'_>,
) -> Result<(), Error>;
}
Expand description
A helper trait to streamline implementing FlowNode
instances that only
ever operate on a single request at a time.
In essence, SimpleFlowNode
handles the boilerplate (and rightward-drift)
of manually writing:
impl FlowNode for Node {
fn imports(dep: &mut ImportCtx<'_>) { ... }
fn emit(requests: Vec<Self::Request>, ctx: &mut NodeCtx<'_>) {
for req in requests {
Node::process_request(req, ctx)
}
}
}
Nodes which accept a struct Request
often fall into this pattern, whereas
nodes which accept a enum Request
typically require additional logic to
aggregate / resolve incoming requests.
Required Associated Types§
type Request: Serialize + DeserializeOwned
Required Methods§
Sourcefn imports(ctx: &mut ImportCtx<'_>)
fn imports(ctx: &mut ImportCtx<'_>)
A list of nodes that this node is capable of taking a dependency on.
Attempting to take a dep on a node that wasn’t imported via this method will result in an error during flow resolution time.
To put it bluntly: This is boilerplate.
We (the flowey devs) are thinking about ways to avoid requiring this method, but do not have a good solution at this time.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.