mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-01 18:17:25 +00:00
c3e45a04fc
* add regression test for missing Send requirement * fix: require the initialization with `F: FnOnce` to be `Send` as well If creating intermediate variables of the builder type within a future, rustc will complain about the future not being send, while the thing itself isn't even using the closure based field initialization. Adding an additional bound, resolves this and pushes the error message "closer" to the user, and out of the generated code. * import fixins
75 lines
1.9 KiB
Rust
75 lines
1.9 KiB
Rust
// Copyright (C) 2022 Parity Technologies (UK) Ltd.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
#![allow(dead_code)] // orchestra events are not used
|
|
|
|
//! A minimal demo to be used with cargo expand.
|
|
|
|
use orchestra::{self as orchestra, Spawner, *};
|
|
mod misc;
|
|
|
|
pub use self::misc::*;
|
|
|
|
#[orchestra(signal=SigSigSig, event=EvX, error=Yikes, gen=AllMessages)]
|
|
struct Solo<T> {
|
|
#[subsystem(consumes: Plinko, sends: [MsgStrukt])]
|
|
goblin_tower: GoblinTower,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct Fortified;
|
|
|
|
#[orchestra::subsystem(GoblinTower, error=Yikes)]
|
|
impl<Context> Fortified {
|
|
fn start(self, mut ctx: Context) -> SpawnedSubsystem<Yikes> {
|
|
let mut sender = ctx.sender().clone();
|
|
ctx.spawn(
|
|
"GoblinTower",
|
|
Box::pin(async move {
|
|
sender.send_message(MsgStrukt(8u8)).await;
|
|
}),
|
|
)
|
|
.unwrap();
|
|
unimplemented!("welcum")
|
|
}
|
|
}
|
|
|
|
async fn setup() {
|
|
let builder = Solo::builder();
|
|
|
|
let builder = builder.goblin_tower(Fortified::default());
|
|
|
|
let builder = builder.spawner(DummySpawner);
|
|
let (orchestra, _handle): (Solo<_>, _) = builder.build().unwrap();
|
|
|
|
let orchestra_fut = orchestra
|
|
.running_subsystems
|
|
.into_future()
|
|
.timeout(std::time::Duration::from_millis(300))
|
|
.fuse();
|
|
|
|
futures::pin_mut!(orchestra_fut);
|
|
|
|
orchestra_fut.await;
|
|
}
|
|
|
|
fn assert_t_impl_trait_send<T: Send>(_: &T) {}
|
|
|
|
fn main() {
|
|
let x = setup();
|
|
assert_t_impl_trait_send(&x);
|
|
futures::executor::block_on(x);
|
|
}
|