Skip to content

Commit

Permalink
convert block constructors to typed variants
Browse files Browse the repository at this point in the history
  • Loading branch information
bastibl committed Nov 15, 2024
1 parent fe380cd commit da7d4e4
Show file tree
Hide file tree
Showing 46 changed files with 168 additions and 165 deletions.
6 changes: 3 additions & 3 deletions examples/adsb/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ 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;
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;
Expand Down Expand Up @@ -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<Self> {
TypedBlock::new(
BlockMetaBuilder::new("Decoder").build(),
StreamIoBuilder::new().build(),
MessageIoBuilder::new()
Expand Down
6 changes: 3 additions & 3 deletions examples/adsb/src/demodulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)]
Expand All @@ -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<Self> {
TypedBlock::new(
BlockMetaBuilder::new("Demodulator").build(),
StreamIoBuilder::new().add_input::<f32>("in").build(),
MessageIoBuilder::new().add_output("out").build(),
Expand Down
6 changes: 3 additions & 3 deletions examples/adsb/src/preamble_detector.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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<Self> {
TypedBlock::new(
BlockMetaBuilder::new("PreambleDetector").build(),
StreamIoBuilder::new()
.add_input::<f32>("in_samples")
Expand Down
10 changes: 5 additions & 5 deletions examples/adsb/src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<Self> {
Tracker::new_with_optional_args(None)
}

pub fn with_pruning(after: Duration) -> Block {
pub fn with_pruning(after: Duration) -> TypedBlock<Self> {
Tracker::new_with_optional_args(Some(after))
}

fn new_with_optional_args(prune_after: Option<Duration>) -> Block {
fn new_with_optional_args(prune_after: Option<Duration>) -> TypedBlock<Self> {
let aircraft_register = AircraftRegister {
register: HashMap::new(),
};
Block::new(
TypedBlock::new(
BlockMetaBuilder::new("Tracker").build(),
StreamIoBuilder::new().build(),
MessageIoBuilder::new()
Expand Down
6 changes: 3 additions & 3 deletions examples/android-hw/src/fft_shift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ 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;
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<T> {
Expand All @@ -18,8 +18,8 @@ pub struct FftShift<T> {

impl<T: Copy + Send + 'static> FftShift<T> {
#[allow(clippy::new_ret_no_self)]
pub fn new() -> Block {
Block::new(
pub fn new() -> TypedBlock<Self> {
TypedBlock::new(
BlockMetaBuilder::new("FftShift").build(),
StreamIoBuilder::new()
.add_input::<T>("in")
Expand Down
6 changes: 3 additions & 3 deletions examples/ctrlport-demo.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<()> {
Expand All @@ -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<Self> {
TypedBlock::new(
BlockMetaBuilder::new("CtrlPortDemo").build(),
StreamIoBuilder::new().build(),
MessageIoBuilder::new()
Expand Down
6 changes: 3 additions & 3 deletions examples/debug/panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)]
Expand Down Expand Up @@ -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<Self> {
TypedBlock::new(
BlockMetaBuilder::new("Panic").build(),
StreamIoBuilder::new().build(),
MessageIoBuilder::<Self>::new().build(),
Expand Down
6 changes: 3 additions & 3 deletions examples/debug/tag_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<()> {
Expand Down Expand Up @@ -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<Self> {
TypedBlock::new(
BlockMetaBuilder::new("PeriodicTagger").build(),
StreamIoBuilder::new()
.add_input::<f32>("in")
Expand Down
6 changes: 3 additions & 3 deletions examples/egui/src/channel_sink.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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;
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;
Expand All @@ -18,8 +18,8 @@ pub struct ChannelSink {
}

impl ChannelSink {
pub fn new(tx: Sender<Box<[f32; FFT_SIZE]>>) -> Block {
Block::new(
pub fn new(tx: Sender<Box<[f32; FFT_SIZE]>>) -> TypedBlock<Self> {
TypedBlock::new(
BlockMetaBuilder::new("ChannelSink").build(),
StreamIoBuilder::new().add_input::<f32>("in").build(),
MessageIoBuilder::<Self>::new().build(),
Expand Down
6 changes: 3 additions & 3 deletions examples/keyfob/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
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;
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;

Expand All @@ -25,8 +25,8 @@ pub struct Decoder {
}

impl Decoder {
pub fn new() -> Block {
Block::new(
pub fn new() -> TypedBlock<Self> {
TypedBlock::new(
BlockMetaBuilder::new("Decoder").build(),
StreamIoBuilder::new().add_input::<u8>("in").build(),
MessageIoBuilder::<Self>::new().build(),
Expand Down
6 changes: 3 additions & 3 deletions examples/lora/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ 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;
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;

Expand All @@ -19,8 +19,8 @@ use crate::Frame;
pub struct Decoder;

impl Decoder {
pub fn new() -> Block {
Block::new(
pub fn new() -> TypedBlock<Self> {
TypedBlock::new(
BlockMetaBuilder::new("Decoder").build(),
StreamIoBuilder::new().build(),
MessageIoBuilder::new()
Expand Down
6 changes: 3 additions & 3 deletions examples/lora/src/deinterleaver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -27,7 +27,7 @@ pub struct Deinterleaver {
}

impl Deinterleaver {
pub fn new(soft_decoding: bool) -> Block {
pub fn new(soft_decoding: bool) -> TypedBlock<Self> {
let mut sio = StreamIoBuilder::new();
if soft_decoding {
sio = sio.add_input::<[LLR; MAX_SF]>("in");
Expand All @@ -36,7 +36,7 @@ impl Deinterleaver {
sio = sio.add_input::<u16>("in");
sio = sio.add_output::<u8>("out");
}
Block::new(
TypedBlock::new(
BlockMetaBuilder::new("Deinterleaver").build(),
sio.build(),
MessageIoBuilder::new().build(),
Expand Down
9 changes: 4 additions & 5 deletions examples/lora/src/fft_demod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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<Self> {
let m_samples_per_symbol = 1_usize << sf_initial;
let fft_plan = FftPlanner::new().plan_fft_forward(m_samples_per_symbol);
let fs = Self {
Expand Down Expand Up @@ -91,7 +90,7 @@ impl FftDemod {
} else {
sio = sio.add_output::<u16>("out")
}
Block::new(
TypedBlock::new(
BlockMetaBuilder::new("FftDemod").build(),
sio.build(),
MessageIoBuilder::new().build(),
Expand Down
Loading

0 comments on commit da7d4e4

Please sign in to comment.