pub fn create_bidir_stream<Req, Resp>(
content_type: &'static str,
provenance: Vec<String>,
) -> (Arc<BidirChannel<Req, Resp>>, impl FnOnce(Pin<Box<dyn Stream<Item = PlexusStreamItem> + Send>>) -> PlexusStream)where
Req: Serialize + DeserializeOwned + Send + Sync + 'static,
Resp: Serialize + DeserializeOwned + Send + Sync + 'static,Expand description
Create a bidirectional channel and wrap a stream, merging Request items
This function:
- Creates a BidirChannel connected to an internal mpsc channel
- Wraps the user’s typed stream into PlexusStreamItems
- Merges in any Request items emitted by the BidirChannel
- Returns both the channel (for the activation to use) and the merged stream
§Arguments
content_type- Content type string for data items (e.g., “interactive.wizard”)provenance- Provenance path for metadata
§Returns
Returns a tuple of:
Arc<BidirChannel<Req, Resp>>- The bidirectional channel for the activation- A closure that takes the user’s stream and returns the merged PlexusStream
§Example
ⓘ
let (ctx, wrap_fn) = create_bidir_stream::<StandardRequest, StandardResponse>(
"interactive.wizard",
vec!["interactive".into()],
);
let user_stream = activation.wizard(&ctx).await;
let merged_stream = wrap_fn(user_stream);