From da7d4e4a19b7de156cb0c1eaf2270f5a665c2988 Mon Sep 17 00:00:00 2001 From: Bastian Bloessl Date: Fri, 15 Nov 2024 15:52:54 +0100 Subject: [PATCH] convert block constructors to typed variants --- examples/adsb/src/decoder.rs | 6 +++--- examples/adsb/src/demodulator.rs | 6 +++--- examples/adsb/src/preamble_detector.rs | 6 +++--- examples/adsb/src/tracker.rs | 10 +++++----- examples/android-hw/src/fft_shift.rs | 6 +++--- examples/ctrlport-demo.rs | 6 +++--- examples/debug/panic.rs | 6 +++--- examples/debug/tag_debug.rs | 6 +++--- examples/egui/src/channel_sink.rs | 6 +++--- examples/keyfob/src/decoder.rs | 6 +++--- examples/lora/src/decoder.rs | 6 +++--- examples/lora/src/deinterleaver.rs | 6 +++--- examples/lora/src/fft_demod.rs | 9 ++++----- examples/lora/src/frame_sync.rs | 13 ++++++------- examples/lora/src/gray_mapping.rs | 6 +++--- examples/lora/src/hamming_dec.rs | 6 +++--- examples/lora/src/header_decoder.rs | 6 +++--- examples/lora/src/packet_forwarder_client.rs | 17 ++++++++--------- examples/lora/src/stream_adder.rs | 6 +++--- examples/lora/src/transmitter.rs | 6 +++--- examples/m17/src/decoder_block.rs | 6 +++--- examples/m17/src/encoder_block.rs | 6 +++--- examples/m17/src/symbol_sync.rs | 6 +++--- examples/macros/src/main.rs | 14 +++++++------- examples/rattlegram/src/decoder.rs | 6 +++--- examples/spectrum/src/vulkan.rs | 6 +++--- examples/spectrum/src/wasm/web.rs | 6 +++--- examples/wlan/src/decoder.rs | 6 +++--- examples/wlan/src/encoder.rs | 6 +++--- examples/wlan/src/frame_equalizer.rs | 20 ++++++++++---------- examples/wlan/src/mac.rs | 6 +++--- examples/wlan/src/mapper.rs | 6 +++--- examples/wlan/src/prefix.rs | 6 +++--- examples/wlan/src/sync_long.rs | 6 +++--- examples/wlan/src/sync_short.rs | 6 +++--- examples/zigbee/src/clock_recovery_mm.rs | 6 +++--- examples/zigbee/src/decoder.rs | 6 +++--- examples/zigbee/src/iq_delay.rs | 6 +++--- examples/zigbee/src/mac.rs | 6 +++--- src/blocks/audio/wav_sink.rs | 2 +- src/blocks/signal_source/mod.rs | 20 +++++++++++++------- src/blocks/zeromq/pub_sink.rs | 2 +- src/blocks/zeromq/sub_source.rs | 2 +- tests/bad_block.rs | 6 +++--- tests/fail.rs | 14 +++++++------- tests/message_handler.rs | 6 +++--- 46 files changed, 168 insertions(+), 165 deletions(-) diff --git a/examples/adsb/src/decoder.rs b/examples/adsb/src/decoder.rs index ab429ffe5..70ae1274a 100644 --- a/examples/adsb/src/decoder.rs +++ b/examples/adsb/src/decoder.rs @@ -4,7 +4,6 @@ use futuresdr::anyhow::bail; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -12,6 +11,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; use futuresdr::tracing::info; @@ -45,8 +45,8 @@ pub struct Decoder { impl Decoder { #[allow(clippy::new_ret_no_self)] - pub fn new(forward_failed_crc: bool) -> Block { - Block::new( + pub fn new(forward_failed_crc: bool) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Decoder").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() diff --git a/examples/adsb/src/demodulator.rs b/examples/adsb/src/demodulator.rs index 6660fea24..7c07b2bf3 100644 --- a/examples/adsb/src/demodulator.rs +++ b/examples/adsb/src/demodulator.rs @@ -3,7 +3,6 @@ use crate::SYMBOL_ONE_TAPS; use crate::SYMBOL_ZERO_TAPS; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -13,6 +12,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; #[derive(Clone, Debug)] @@ -28,8 +28,8 @@ pub struct Demodulator { impl Demodulator { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Demodulator").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::new().add_output("out").build(), diff --git a/examples/adsb/src/preamble_detector.rs b/examples/adsb/src/preamble_detector.rs index 9ee53feec..af456379a 100644 --- a/examples/adsb/src/preamble_detector.rs +++ b/examples/adsb/src/preamble_detector.rs @@ -1,7 +1,6 @@ use crate::N_SAMPLES_PER_HALF_SYM; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -10,6 +9,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; pub struct PreambleDetector { @@ -38,8 +38,8 @@ impl PreambleDetector { } #[allow(clippy::new_ret_no_self)] - pub fn new(detection_threshold: f32) -> Block { - Block::new( + pub fn new(detection_threshold: f32) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("PreambleDetector").build(), StreamIoBuilder::new() .add_input::("in_samples") diff --git a/examples/adsb/src/tracker.rs b/examples/adsb/src/tracker.rs index ff25bdcbe..908037c1a 100644 --- a/examples/adsb/src/tracker.rs +++ b/examples/adsb/src/tracker.rs @@ -2,7 +2,6 @@ use futuresdr::anyhow::Result; use futuresdr::async_io::Timer; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -11,6 +10,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::info; use futuresdr::tracing::warn; @@ -33,19 +33,19 @@ pub struct Tracker { impl Tracker { /// Creates a new tracker without pruning. #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { + pub fn new() -> TypedBlock { Tracker::new_with_optional_args(None) } - pub fn with_pruning(after: Duration) -> Block { + pub fn with_pruning(after: Duration) -> TypedBlock { Tracker::new_with_optional_args(Some(after)) } - fn new_with_optional_args(prune_after: Option) -> Block { + fn new_with_optional_args(prune_after: Option) -> TypedBlock { let aircraft_register = AircraftRegister { register: HashMap::new(), }; - Block::new( + TypedBlock::new( BlockMetaBuilder::new("Tracker").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() diff --git a/examples/android-hw/src/fft_shift.rs b/examples/android-hw/src/fft_shift.rs index 5b743c4c6..34b934ef2 100644 --- a/examples/android-hw/src/fft_shift.rs +++ b/examples/android-hw/src/fft_shift.rs @@ -2,7 +2,6 @@ use std::marker::PhantomData; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -10,6 +9,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; pub struct FftShift { @@ -18,8 +18,8 @@ pub struct FftShift { impl FftShift { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("FftShift").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/ctrlport-demo.rs b/examples/ctrlport-demo.rs index 8fc55c45c..b505f148a 100644 --- a/examples/ctrlport-demo.rs +++ b/examples/ctrlport-demo.rs @@ -1,7 +1,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Flowgraph; @@ -11,6 +10,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; fn main() -> Result<()> { @@ -28,8 +28,8 @@ pub struct CtrlPortDemo { impl CtrlPortDemo { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("CtrlPortDemo").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() diff --git a/examples/debug/panic.rs b/examples/debug/panic.rs index ba75074e7..58928d7f6 100644 --- a/examples/debug/panic.rs +++ b/examples/debug/panic.rs @@ -5,7 +5,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::macros::connect; use futuresdr::runtime::scheduler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Flowgraph; @@ -15,6 +14,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; #[derive(Debug, Clone, ValueEnum)] @@ -69,8 +69,8 @@ struct Panic { impl Panic { #[allow(clippy::new_ret_no_self)] - pub fn new(w: PanicWhere) -> Block { - Block::new( + pub fn new(w: PanicWhere) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Panic").build(), StreamIoBuilder::new().build(), MessageIoBuilder::::new().build(), diff --git a/examples/debug/tag_debug.rs b/examples/debug/tag_debug.rs index 6fecfc01e..aa20bc078 100644 --- a/examples/debug/tag_debug.rs +++ b/examples/debug/tag_debug.rs @@ -2,7 +2,6 @@ use futuresdr::anyhow::Result; use futuresdr::blocks::TagDebug; use futuresdr::blocks::VectorSource; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Flowgraph; @@ -13,6 +12,7 @@ use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; fn main() -> Result<()> { @@ -44,8 +44,8 @@ pub struct PeriodicTagger { impl PeriodicTagger { #[allow(clippy::new_ret_no_self)] - pub fn new(period: usize) -> Block { - Block::new( + pub fn new(period: usize) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("PeriodicTagger").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/egui/src/channel_sink.rs b/examples/egui/src/channel_sink.rs index 66eaee399..402b51742 100644 --- a/examples/egui/src/channel_sink.rs +++ b/examples/egui/src/channel_sink.rs @@ -1,7 +1,6 @@ use futuresdr::anyhow::Result; use futuresdr::futures::channel::mpsc::Sender; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -9,6 +8,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use crate::FFT_SIZE; @@ -18,8 +18,8 @@ pub struct ChannelSink { } impl ChannelSink { - pub fn new(tx: Sender>) -> Block { - Block::new( + pub fn new(tx: Sender>) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("ChannelSink").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::::new().build(), diff --git a/examples/keyfob/src/decoder.rs b/examples/keyfob/src/decoder.rs index 264eb743b..303105620 100644 --- a/examples/keyfob/src/decoder.rs +++ b/examples/keyfob/src/decoder.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -8,6 +7,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::info; @@ -25,8 +25,8 @@ pub struct Decoder { } impl Decoder { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Decoder").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::::new().build(), diff --git a/examples/lora/src/decoder.rs b/examples/lora/src/decoder.rs index 7c012d583..14061a4a6 100644 --- a/examples/lora/src/decoder.rs +++ b/examples/lora/src/decoder.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -10,6 +9,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::info; @@ -19,8 +19,8 @@ use crate::Frame; pub struct Decoder; impl Decoder { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Decoder").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() diff --git a/examples/lora/src/deinterleaver.rs b/examples/lora/src/deinterleaver.rs index 617b161bf..65c2d8af4 100644 --- a/examples/lora/src/deinterleaver.rs +++ b/examples/lora/src/deinterleaver.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -13,6 +12,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::warn; @@ -27,7 +27,7 @@ pub struct Deinterleaver { } impl Deinterleaver { - pub fn new(soft_decoding: bool) -> Block { + pub fn new(soft_decoding: bool) -> TypedBlock { let mut sio = StreamIoBuilder::new(); if soft_decoding { sio = sio.add_input::<[LLR; MAX_SF]>("in"); @@ -36,7 +36,7 @@ impl Deinterleaver { sio = sio.add_input::("in"); sio = sio.add_output::("out"); } - Block::new( + TypedBlock::new( BlockMetaBuilder::new("Deinterleaver").build(), sio.build(), MessageIoBuilder::new().build(), diff --git a/examples/lora/src/fft_demod.rs b/examples/lora/src/fft_demod.rs index 74aee9667..f7f80e4ad 100644 --- a/examples/lora/src/fft_demod.rs +++ b/examples/lora/src/fft_demod.rs @@ -1,13 +1,11 @@ +use rustfft::FftPlanner; use std::collections::HashMap; use std::sync::Arc; -use rustfft::FftPlanner; - use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; use futuresdr::num_complex::Complex64; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -18,6 +16,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::warn; @@ -62,7 +61,7 @@ pub struct FftDemod { } impl FftDemod { - pub fn new(soft_decoding: bool, sf_initial: usize) -> Block { + pub fn new(soft_decoding: bool, sf_initial: usize) -> TypedBlock { let m_samples_per_symbol = 1_usize << sf_initial; let fft_plan = FftPlanner::new().plan_fft_forward(m_samples_per_symbol); let fs = Self { @@ -91,7 +90,7 @@ impl FftDemod { } else { sio = sio.add_output::("out") } - Block::new( + TypedBlock::new( BlockMetaBuilder::new("FftDemod").build(), sio.build(), MessageIoBuilder::new().build(), diff --git a/examples/lora/src/frame_sync.rs b/examples/lora/src/frame_sync.rs index eb3b08039..c1c150552 100644 --- a/examples/lora/src/frame_sync.rs +++ b/examples/lora/src/frame_sync.rs @@ -1,3 +1,6 @@ +use rustfft::Fft; +use rustfft::FftDirection; +use rustfft::FftPlanner; use std::collections::HashMap; use std::f32::consts::PI; use std::str::FromStr; @@ -5,16 +8,11 @@ use std::sync::Arc; use std::time::SystemTime; use std::time::UNIX_EPOCH; -use rustfft::Fft; -use rustfft::FftDirection; -use rustfft::FftPlanner; - use futuresdr::anyhow::Result; use futuresdr::futures::channel::mpsc; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -24,6 +22,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; use futuresdr::tracing::info; @@ -185,7 +184,7 @@ impl FrameSync { net_id_caching_policy: Option<&str>, collect_receive_statistics: bool, startup_timestamp: Option, - ) -> Block { + ) -> TypedBlock { let net_id_caching_policy_tmp = match NetIdCachingPolicy::from_str(net_id_caching_policy.unwrap_or("header_crc_ok")) { Ok(tmp) => tmp, Err(_) => panic!("Supplied invalid value for parameter net_id_caching_policy. Possible values: 'none', 'seen', 'header_crc_ok', 'payload_crc_ok'"), @@ -208,7 +207,7 @@ impl FrameSync { let fft_detect = FftPlanner::new().plan_fft(m_number_of_bins_tmp, FftDirection::Forward); - Block::new( + TypedBlock::new( BlockMetaBuilder::new("FrameSync").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/lora/src/gray_mapping.rs b/examples/lora/src/gray_mapping.rs index deca0a8f1..2cc942bf0 100644 --- a/examples/lora/src/gray_mapping.rs +++ b/examples/lora/src/gray_mapping.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -11,6 +10,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use std::cmp::min; use std::collections::HashMap; @@ -23,7 +23,7 @@ pub struct GrayMapping { } impl GrayMapping { - pub fn new(soft_decoding: bool) -> Block { + pub fn new(soft_decoding: bool) -> TypedBlock { let mut sio = StreamIoBuilder::new(); if soft_decoding { sio = sio.add_input::<[LLR; MAX_SF]>("in"); @@ -32,7 +32,7 @@ impl GrayMapping { sio = sio.add_input::("in"); sio = sio.add_output::("out"); } - Block::new( + TypedBlock::new( BlockMetaBuilder::new("GrayMapping").build(), sio.build(), MessageIoBuilder::new().build(), diff --git a/examples/lora/src/hamming_dec.rs b/examples/lora/src/hamming_dec.rs index 552fd22ff..073b7190a 100644 --- a/examples/lora/src/hamming_dec.rs +++ b/examples/lora/src/hamming_dec.rs @@ -4,7 +4,6 @@ use std::collections::VecDeque; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -15,6 +14,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use crate::utils::*; @@ -47,7 +47,7 @@ pub struct HammingDec { } impl HammingDec { - pub fn new(soft_decoding: bool) -> Block { + pub fn new(soft_decoding: bool) -> TypedBlock { let mut sio = StreamIoBuilder::new(); if soft_decoding { sio = sio.add_input::<[LLR; 8]>("in"); // In reality: cw_len = cr_app + 4 < 8 @@ -55,7 +55,7 @@ impl HammingDec { sio = sio.add_input::("in"); } sio = sio.add_output::("out"); - Block::new( + TypedBlock::new( BlockMetaBuilder::new("HammingDec").build(), sio.build(), MessageIoBuilder::new().add_output("out").build(), diff --git a/examples/lora/src/header_decoder.rs b/examples/lora/src/header_decoder.rs index e6fadcc43..0d0345eec 100644 --- a/examples/lora/src/header_decoder.rs +++ b/examples/lora/src/header_decoder.rs @@ -3,7 +3,6 @@ use std::collections::HashMap; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -14,6 +13,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; use futuresdr::tracing::info; @@ -58,8 +58,8 @@ pub struct HeaderDecoder { } impl HeaderDecoder { - pub fn new(mode: HeaderMode, ldro_mode: bool) -> Block { - Block::new( + pub fn new(mode: HeaderMode, ldro_mode: bool) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("HeaderDecoder").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::new() diff --git a/examples/lora/src/packet_forwarder_client.rs b/examples/lora/src/packet_forwarder_client.rs index 25081d5b4..4bc07f31c 100644 --- a/examples/lora/src/packet_forwarder_client.rs +++ b/examples/lora/src/packet_forwarder_client.rs @@ -1,8 +1,3 @@ -use std::net::SocketAddr; -use std::str::FromStr; -use std::time::Duration; -use std::time::SystemTime; - use chrono::prelude::DateTime; use chrono::prelude::Utc; use semtech_udp::client_runtime::Event; @@ -17,6 +12,10 @@ use semtech_udp::CodingRate; use semtech_udp::DataRate; use semtech_udp::MacAddress; use semtech_udp::SpreadingFactor; +use std::net::SocketAddr; +use std::str::FromStr; +use std::time::Duration; +use std::time::SystemTime; use tokio::runtime::Runtime; use triggered::Trigger; @@ -26,7 +25,6 @@ use futuresdr::futures::SinkExt; use futuresdr::futures_lite::StreamExt; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -34,6 +32,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; /// Forward messages. @@ -46,7 +45,7 @@ pub struct PacketForwarderClient { } impl PacketForwarderClient { - pub fn new(mac_addr: &str, server_addr: &str) -> Block { + pub fn new(mac_addr: &str, server_addr: &str) -> TypedBlock { let mac_address = MacAddress::from_str(mac_addr).unwrap(); let (to_forwarder_sender, mut to_forwarder_receiver) = mpsc::channel::(1); let host = SocketAddr::from_str(server_addr).unwrap(); @@ -96,8 +95,8 @@ impl PacketForwarderClient { }); }); - Block::new( - BlockMetaBuilder::new("MessageCopy").build(), + TypedBlock::new( + BlockMetaBuilder::new("PacketForwarder").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() .add_input("in", Self::handler) diff --git a/examples/lora/src/stream_adder.rs b/examples/lora/src/stream_adder.rs index 27203907f..f84d657f2 100644 --- a/examples/lora/src/stream_adder.rs +++ b/examples/lora/src/stream_adder.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -8,6 +7,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use std::cmp::min; use std::marker::PhantomData; @@ -22,13 +22,13 @@ impl StreamAdder where T: Copy + Send + Sync + Add + 'static, { - pub fn new(num_inputs: usize) -> Block { + pub fn new(num_inputs: usize) -> TypedBlock { let mut sio = StreamIoBuilder::new(); for i in 0..num_inputs { sio = sio.add_input::(&format!("in{}", i)); } sio = sio.add_output::("out"); - Block::new( + TypedBlock::new( BlockMetaBuilder::new("StreamAdder").build(), sio.build(), MessageIoBuilder::new().build(), diff --git a/examples/lora/src/transmitter.rs b/examples/lora/src/transmitter.rs index f8aba7862..87306cf9f 100644 --- a/examples/lora/src/transmitter.rs +++ b/examples/lora/src/transmitter.rs @@ -2,7 +2,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -11,6 +10,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::warn; use std::collections::VecDeque; @@ -39,8 +39,8 @@ impl Transmitter { sync_words: Vec, preamble_len: usize, pad: usize, - ) -> Block { - Block::new( + ) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Transmitter").build(), StreamIoBuilder::new() .add_output::("out") diff --git a/examples/m17/src/decoder_block.rs b/examples/m17/src/decoder_block.rs index 0bfa548a1..0fe9af7f7 100644 --- a/examples/m17/src/decoder_block.rs +++ b/examples/m17/src/decoder_block.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -8,6 +7,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use crate::Decoder; @@ -17,8 +17,8 @@ pub struct DecoderBlock { } impl DecoderBlock { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("M17Decoder").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/m17/src/encoder_block.rs b/examples/m17/src/encoder_block.rs index 32c1be44f..01bb50277 100644 --- a/examples/m17/src/encoder_block.rs +++ b/examples/m17/src/encoder_block.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -8,6 +7,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use crate::Encoder; @@ -20,8 +20,8 @@ pub struct EncoderBlock { } impl EncoderBlock { - pub fn new(lsf: LinkSetupFrame) -> Block { - Block::new( + pub fn new(lsf: LinkSetupFrame) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("M17Encoder").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/m17/src/symbol_sync.rs b/examples/m17/src/symbol_sync.rs index c6b89f6ee..ca5627656 100644 --- a/examples/m17/src/symbol_sync.rs +++ b/examples/m17/src/symbol_sync.rs @@ -2,7 +2,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; use futuresdr::num_integer::Integer; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -10,6 +9,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use std::collections::VecDeque; @@ -1761,7 +1761,7 @@ impl SymbolSync { ted_gain: f32, max_deviation: f32, osps: usize, - ) -> Block { + ) -> TypedBlock { assert!(sps > 1.0); assert!(osps >= 1); @@ -1804,7 +1804,7 @@ impl SymbolSync { s.interp.sync_reset(sps); // let filter_delay = (s.interp.ntaps() + 1) / 2; - Block::new( + TypedBlock::new( BlockMetaBuilder::new("SymbolSync").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/macros/src/main.rs b/examples/macros/src/main.rs index 9e7ef2a27..a5fd5e377 100644 --- a/examples/macros/src/main.rs +++ b/examples/macros/src/main.rs @@ -8,7 +8,6 @@ use futuresdr::blocks::VectorSource; use futuresdr::macros::async_trait; use futuresdr::macros::connect; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Flowgraph; @@ -19,6 +18,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; fn main() -> Result<()> { @@ -75,8 +75,8 @@ pub struct Dummy; impl Dummy { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Dummy").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new().build(), @@ -103,8 +103,8 @@ pub struct Strange; impl Strange { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Strange").build(), StreamIoBuilder::new().add_output::("foo bar").build(), MessageIoBuilder::new().build(), @@ -131,8 +131,8 @@ pub struct Handler; impl Handler { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Handler").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() diff --git a/examples/rattlegram/src/decoder.rs b/examples/rattlegram/src/decoder.rs index 7e5d0b1e9..cd89618e0 100644 --- a/examples/rattlegram/src/decoder.rs +++ b/examples/rattlegram/src/decoder.rs @@ -1,7 +1,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -9,6 +8,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::info; use rustfft::Fft; @@ -30,8 +30,8 @@ pub struct DecoderBlock { } impl DecoderBlock { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("RattegramDecoder").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::new().build(), diff --git a/examples/spectrum/src/vulkan.rs b/examples/spectrum/src/vulkan.rs index 167968ad4..8b68ce427 100644 --- a/examples/spectrum/src/vulkan.rs +++ b/examples/spectrum/src/vulkan.rs @@ -23,7 +23,6 @@ use futuresdr::runtime::buffer::vulkan::BufferEmpty; use futuresdr::runtime::buffer::vulkan::ReaderH2D; use futuresdr::runtime::buffer::vulkan::WriterD2H; use futuresdr::runtime::buffer::BufferReaderCustom; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -31,6 +30,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; @@ -67,13 +67,13 @@ pub struct Vulkan { } impl Vulkan { - pub fn new(broker: Arc, capacity: u64) -> Block { + pub fn new(broker: Arc, capacity: u64) -> TypedBlock { let memory_allocator = StandardMemoryAllocator::new_default(broker.device().clone()); let descriptor_set_allocator = StandardDescriptorSetAllocator::new(broker.device().clone()); let command_buffer_allocator = StandardCommandBufferAllocator::new(broker.device().clone(), Default::default()); - Block::new( + TypedBlock::new( BlockMetaBuilder::new("Vulkan").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/spectrum/src/wasm/web.rs b/examples/spectrum/src/wasm/web.rs index 28bbc4e34..80ce01286 100644 --- a/examples/spectrum/src/wasm/web.rs +++ b/examples/spectrum/src/wasm/web.rs @@ -18,7 +18,6 @@ use futuresdr::blocks::FftDirection; use futuresdr::blocks::MovingAvg; use futuresdr::macros::async_trait; use futuresdr::macros::connect; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Flowgraph; @@ -30,6 +29,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; const FFT_SIZE: usize = 2048; @@ -220,8 +220,8 @@ unsafe impl Send for Sink {} impl Sink { #[allow(clippy::new_ret_no_self)] - pub fn new(data: Vec>>>>) -> Block { - Block::new( + pub fn new(data: Vec>>>>) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Sink").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::new().build(), diff --git a/examples/wlan/src/decoder.rs b/examples/wlan/src/decoder.rs index f08dd20aa..576272b88 100644 --- a/examples/wlan/src/decoder.rs +++ b/examples/wlan/src/decoder.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -11,6 +10,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::warn; @@ -34,8 +34,8 @@ pub struct Decoder { } impl Decoder { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Decoder").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::new() diff --git a/examples/wlan/src/encoder.rs b/examples/wlan/src/encoder.rs index 6564c3b67..b83506582 100644 --- a/examples/wlan/src/encoder.rs +++ b/examples/wlan/src/encoder.rs @@ -6,7 +6,6 @@ use crate::MAX_PSDU_SIZE; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -16,6 +15,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::warn; use std::collections::VecDeque; @@ -39,8 +39,8 @@ pub struct Encoder { } impl Encoder { - pub fn new(default_mcs: Mcs) -> Block { - Block::new( + pub fn new(default_mcs: Mcs) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Encoder").build(), StreamIoBuilder::new().add_output::("out").build(), MessageIoBuilder::new() diff --git a/examples/wlan/src/frame_equalizer.rs b/examples/wlan/src/frame_equalizer.rs index 482e28029..e0a8d0ace 100644 --- a/examples/wlan/src/frame_equalizer.rs +++ b/examples/wlan/src/frame_equalizer.rs @@ -1,14 +1,6 @@ -use crate::FrameParam; -use crate::Mcs; -use crate::Modulation; -use crate::ViterbiDecoder; -use crate::LONG; -use crate::POLARITY; - use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -19,9 +11,17 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::info; +use crate::FrameParam; +use crate::Mcs; +use crate::Modulation; +use crate::ViterbiDecoder; +use crate::LONG; +use crate::POLARITY; + const INTERLEAVER_PATTERN: [usize; 48] = [ 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, @@ -102,8 +102,8 @@ pub struct FrameEqualizer { } impl FrameEqualizer { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("FrameEqualizer").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/wlan/src/mac.rs b/examples/wlan/src/mac.rs index f5addb7c2..7c3a803b8 100644 --- a/examples/wlan/src/mac.rs +++ b/examples/wlan/src/mac.rs @@ -4,7 +4,6 @@ use crate::MAX_PSDU_SIZE; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -12,6 +11,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; use futuresdr::tracing::warn; @@ -22,7 +22,7 @@ pub struct Mac { } impl Mac { - pub fn new(src_mac: [u8; 6], dst_mac: [u8; 6], bss_mac: [u8; 6]) -> Block { + pub fn new(src_mac: [u8; 6], dst_mac: [u8; 6], bss_mac: [u8; 6]) -> TypedBlock { let mut current_frame = [0; MAX_PSDU_SIZE]; // frame control @@ -34,7 +34,7 @@ impl Mac { current_frame[10..16].copy_from_slice(&dst_mac); current_frame[16..22].copy_from_slice(&bss_mac); - Block::new( + TypedBlock::new( BlockMetaBuilder::new("Mac").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new() diff --git a/examples/wlan/src/mapper.rs b/examples/wlan/src/mapper.rs index e85b6588d..3a71dd670 100644 --- a/examples/wlan/src/mapper.rs +++ b/examples/wlan/src/mapper.rs @@ -5,7 +5,6 @@ use crate::POLARITY; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -15,6 +14,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; pub struct Mapper { @@ -27,8 +27,8 @@ pub struct Mapper { } impl Mapper { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Mapper").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/wlan/src/prefix.rs b/examples/wlan/src/prefix.rs index f4e0bb9c0..9449c59ae 100644 --- a/examples/wlan/src/prefix.rs +++ b/examples/wlan/src/prefix.rs @@ -1,7 +1,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -11,6 +10,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; pub struct Prefix { @@ -19,8 +19,8 @@ pub struct Prefix { } impl Prefix { - pub fn new(pad_front: usize, pad_tail: usize) -> Block { - Block::new( + pub fn new(pad_front: usize, pad_tail: usize) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Prefix").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/wlan/src/sync_long.rs b/examples/wlan/src/sync_long.rs index d194029ad..2c3c458c5 100644 --- a/examples/wlan/src/sync_long.rs +++ b/examples/wlan/src/sync_long.rs @@ -1,7 +1,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -11,6 +10,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; const SEARCH_WINDOW: usize = 320; @@ -29,8 +29,8 @@ pub struct SyncLong { } impl SyncLong { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("SyncLong").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/wlan/src/sync_short.rs b/examples/wlan/src/sync_short.rs index de41d8545..2db302e7f 100644 --- a/examples/wlan/src/sync_short.rs +++ b/examples/wlan/src/sync_short.rs @@ -1,7 +1,6 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -10,6 +9,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; const MIN_GAP: usize = 480; @@ -28,8 +28,8 @@ pub struct SyncShort { } impl SyncShort { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("SyncShort").build(), StreamIoBuilder::new() .add_input::("in_sig") diff --git a/examples/zigbee/src/clock_recovery_mm.rs b/examples/zigbee/src/clock_recovery_mm.rs index 7e5e35d56..fa3e16b07 100644 --- a/examples/zigbee/src/clock_recovery_mm.rs +++ b/examples/zigbee/src/clock_recovery_mm.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -8,6 +7,7 @@ use futuresdr::runtime::MessageIo; use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; pub struct ClockRecoveryMm { @@ -28,8 +28,8 @@ impl ClockRecoveryMm { mu: f32, gain_mu: f32, omega_relative_limit: f32, - ) -> Block { - Block::new( + ) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("ClockRecoveryMm").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/zigbee/src/decoder.rs b/examples/zigbee/src/decoder.rs index c5e47f104..3045558d4 100644 --- a/examples/zigbee/src/decoder.rs +++ b/examples/zigbee/src/decoder.rs @@ -1,6 +1,5 @@ use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -9,6 +8,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; const CHIP_MAPPING: [u32; 16] = [ @@ -56,8 +56,8 @@ pub struct Decoder { } impl Decoder { - pub fn new(threshold: u32) -> Block { - Block::new( + pub fn new(threshold: u32) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("Decoder").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::::new().add_output("out").build(), diff --git a/examples/zigbee/src/iq_delay.rs b/examples/zigbee/src/iq_delay.rs index b76084bd8..241bb5649 100644 --- a/examples/zigbee/src/iq_delay.rs +++ b/examples/zigbee/src/iq_delay.rs @@ -3,7 +3,6 @@ use std::collections::VecDeque; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::num_complex::Complex32; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::ItemTag; @@ -13,6 +12,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; #[derive(PartialEq, Eq)] @@ -30,8 +30,8 @@ pub struct IqDelay { } impl IqDelay { - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("IQ Delay").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/examples/zigbee/src/mac.rs b/examples/zigbee/src/mac.rs index 0f95e3d07..8ddcab28d 100644 --- a/examples/zigbee/src/mac.rs +++ b/examples/zigbee/src/mac.rs @@ -3,7 +3,6 @@ use std::collections::VecDeque; use futuresdr::anyhow::Result; use futuresdr::macros::async_trait; use futuresdr::macros::message_handler; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -13,6 +12,7 @@ use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; use futuresdr::runtime::Tag; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; use futuresdr::tracing::info; @@ -36,7 +36,7 @@ pub struct Mac { } impl Mac { - pub fn new() -> Block { + pub fn new() -> TypedBlock { let mut b = [0; 256]; b[0] = 0x0; b[1] = 0x0; @@ -53,7 +53,7 @@ impl Mac { b[12] = SOURCE_ADDRESS.to_le_bytes()[0]; b[13] = SOURCE_ADDRESS.to_le_bytes()[1]; - Block::new( + TypedBlock::new( BlockMetaBuilder::new("Mac").build(), StreamIoBuilder::new().add_output::("out").build(), MessageIoBuilder::new() diff --git a/src/blocks/audio/wav_sink.rs b/src/blocks/audio/wav_sink.rs index 6a1ad8697..13aad4d5e 100644 --- a/src/blocks/audio/wav_sink.rs +++ b/src/blocks/audio/wav_sink.rs @@ -50,7 +50,7 @@ impl WavSink { spec: hound::WavSpec, ) -> TypedBlock { let writer = hound::WavWriter::create(file_name, spec).unwrap(); - TYpedBlock::new( + TypedBlock::new( BlockMetaBuilder::new("WavSink").build(), StreamIoBuilder::new().add_input::("in").build(), MessageIoBuilder::new().build(), diff --git a/src/blocks/signal_source/mod.rs b/src/blocks/signal_source/mod.rs index be9a2a4d7..18e74a8a2 100644 --- a/src/blocks/signal_source/mod.rs +++ b/src/blocks/signal_source/mod.rs @@ -9,6 +9,7 @@ use crate::runtime::MessageIo; use crate::runtime::MessageIoBuilder; use crate::runtime::StreamIo; use crate::runtime::StreamIoBuilder; +use crate::runtime::TypedBlock; use crate::runtime::WorkIo; mod fxpt_phase; @@ -35,8 +36,8 @@ where A: Copy + Send + 'static + std::ops::Mul + std::ops::Add, { /// Create SignalSource block - pub fn new(phase_to_amplitude: F, nco: NCO, amplitude: A, offset: A) -> Block { - Block::new( + pub fn new(phase_to_amplitude: F, nco: NCO, amplitude: A, offset: A) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("SignalSource").build(), StreamIoBuilder::new().add_output::("out").build(), MessageIoBuilder::::new().build(), @@ -160,13 +161,15 @@ impl SignalSourceBuilder { nco, self.amplitude, self.offset, - ), + ) + .into(), WaveForm::Sin => SignalSource::new( |phase: FixedPointPhase| phase.sin(), nco, self.amplitude, self.offset, - ), + ) + .into(), WaveForm::Square => SignalSource::new( |phase: FixedPointPhase| { if phase.value < 0 { @@ -178,7 +181,8 @@ impl SignalSourceBuilder { nco, self.amplitude, self.offset, - ), + ) + .into(), } } } @@ -231,7 +235,8 @@ impl SignalSourceBuilder { nco, self.amplitude, self.offset, - ), + ) + .into(), WaveForm::Square => SignalSource::new( |phase: FixedPointPhase| { let t = phase.value >> 30; @@ -246,7 +251,8 @@ impl SignalSourceBuilder { nco, self.amplitude, self.offset, - ), + ) + .into(), } } } diff --git a/src/blocks/zeromq/pub_sink.rs b/src/blocks/zeromq/pub_sink.rs index 8ffa61c6a..ad943aa53 100644 --- a/src/blocks/zeromq/pub_sink.rs +++ b/src/blocks/zeromq/pub_sink.rs @@ -108,7 +108,7 @@ impl PubSinkBuilder { } /// Build PubSink - pub fn build(self) -> Block { + pub fn build(self) -> TypedBlock> { PubSink::::new(self.address, self.min_item) } } diff --git a/src/blocks/zeromq/sub_source.rs b/src/blocks/zeromq/sub_source.rs index b1150341a..d5c592cda 100644 --- a/src/blocks/zeromq/sub_source.rs +++ b/src/blocks/zeromq/sub_source.rs @@ -93,7 +93,7 @@ impl SubSourceBuilder { } /// Build ZMQ source - pub fn build(self) -> Block { + pub fn build(self) -> TypedBlock> { SubSource::::new(self.address) } } diff --git a/tests/bad_block.rs b/tests/bad_block.rs index 619cd5b7a..f04cc1525 100644 --- a/tests/bad_block.rs +++ b/tests/bad_block.rs @@ -7,7 +7,6 @@ use futuresdr::blocks::NullSource; use futuresdr::blocks::Throttle; use futuresdr::macros::async_trait; use futuresdr::macros::connect; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Error; @@ -18,6 +17,7 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; use futuresdr::tracing::debug; use std::cmp; @@ -37,8 +37,8 @@ pub struct BadBlock { } impl BadBlock { - pub fn to_block(self) -> Block { - Block::new( + pub fn to_block(self) -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("BadBlock").build(), StreamIoBuilder::new() .add_input::("in") diff --git a/tests/fail.rs b/tests/fail.rs index 79ad496cd..8e9686000 100644 --- a/tests/fail.rs +++ b/tests/fail.rs @@ -2,7 +2,6 @@ use futuresdr::anyhow::bail; use futuresdr::anyhow::Result; use futuresdr::blocks::MessageSink; use futuresdr::macros::async_trait; -use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Flowgraph; @@ -12,14 +11,15 @@ use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Runtime; use futuresdr::runtime::StreamIo; use futuresdr::runtime::StreamIoBuilder; +use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; struct FailInit; impl FailInit { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("FailInit").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new().build(), @@ -44,8 +44,8 @@ struct FailWork; impl FailWork { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("FailWork").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new().build(), @@ -71,8 +71,8 @@ struct FailDeinit; impl FailDeinit { #[allow(clippy::new_ret_no_self)] - pub fn new() -> Block { - Block::new( + pub fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("FailDeinit").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new().build(), diff --git a/tests/message_handler.rs b/tests/message_handler.rs index bc321aa3d..96ebd3092 100644 --- a/tests/message_handler.rs +++ b/tests/message_handler.rs @@ -5,7 +5,6 @@ mod isolated_scope { #[test] fn message_handler_compiles() { use futuresdr::macros::message_handler; - use futuresdr::runtime::Block; use futuresdr::runtime::BlockMeta; use futuresdr::runtime::BlockMetaBuilder; use futuresdr::runtime::Kernel; @@ -13,14 +12,15 @@ mod isolated_scope { use futuresdr::runtime::MessageIoBuilder; use futuresdr::runtime::Pmt; use futuresdr::runtime::StreamIoBuilder; + use futuresdr::runtime::TypedBlock; use futuresdr::runtime::WorkIo; struct MsgThing; impl MsgThing { #[allow(clippy::new_ret_no_self)] - fn new() -> Block { - Block::new( + fn new() -> TypedBlock { + TypedBlock::new( BlockMetaBuilder::new("MsgThing").build(), StreamIoBuilder::new().build(), MessageIoBuilder::new()