Improve handling of the generic baggage fields (#5656)

* Parse generic baggage types more carefully to preserve inner structure

* Add example

* Way too many clones

* Allow multiple generic arguments for baggage fields

* Try to detect errors earlier

* Support more types for the baggage fields, get rid of the path constraint
This commit is contained in:
Vsevolod Stakhov
2022-06-14 13:38:26 +01:00
committed by GitHub
parent 11357d4095
commit 7f4205c462
4 changed files with 98 additions and 35 deletions
+8 -6
View File
@@ -18,7 +18,7 @@
//! A dummy to be used with cargo expand
use orchestra::{self as orchestra, Spawner, *};
use std::collections::HashMap;
use std::{collections::HashMap, sync::Arc};
mod misc;
pub use self::misc::*;
@@ -61,7 +61,7 @@ impl<Context> Fortified {
}
#[orchestra(signal=SigSigSig, event=EvX, error=Yikes, gen=AllMessages)]
struct Duo<T> {
struct Duo<T, U, V, W> {
#[subsystem(consumes: MsgStrukt, sends: [Plinko])]
sub0: Awesome,
@@ -69,19 +69,21 @@ struct Duo<T> {
plinkos: GoblinTower,
i_like_pi: f64,
i_like_generic: T,
i_like_hash: HashMap<f64, f64>,
i_like_tuple: (f64, f64),
i_like_generic: Arc<T>,
i_like_hash: HashMap<(U, V), Arc<W>>,
}
fn main() {
use futures::{executor, pin_mut};
executor::block_on(async move {
let (orchestra, _handle): (Duo<_, f64>, _) = Duo::builder()
let (orchestra, _handle): (Duo<_, f64, u32, f32, f64>, _) = Duo::builder()
.sub0(AwesomeSubSys::default())
.plinkos(Fortified::default())
.i_like_pi(::std::f64::consts::PI)
.i_like_generic(42.0)
.i_like_tuple((::std::f64::consts::PI, ::std::f64::consts::PI))
.i_like_generic(Arc::new(42.0))
.i_like_hash(HashMap::new())
.spawner(DummySpawner)
.build()