Skip to content

Commit

Permalink
create custom result type
Browse files Browse the repository at this point in the history
  • Loading branch information
bastibl committed Nov 18, 2024
1 parent 7d62a94 commit 9d8b741
Show file tree
Hide file tree
Showing 231 changed files with 417 additions and 421 deletions.
7 changes: 3 additions & 4 deletions benches/flowgraph.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use anyhow::Result;
use criterion::black_box;
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::Criterion;
use std::time::Duration;
use std::time::Instant;

use futuresdr::anyhow::Result;
use futuresdr::blocks::Copy;
use futuresdr::blocks::Head;
use futuresdr::blocks::NullSource;
use futuresdr::blocks::VectorSinkBuilder;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use std::time::Duration;
use std::time::Instant;

fn run_fg(n_samp: u64) -> Result<()> {
let mut fg = Flowgraph::new();
Expand Down
8 changes: 4 additions & 4 deletions crates/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ pub fn message_handler(
#mio: &'a mut MessageIo<Self>,
#meta: &'a mut BlockMeta,
#pmt: Pmt,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::anyhow::Result<Pmt>> + Send + 'a>> {
) -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::runtime::Result<Pmt>> + Send + 'a>> {
use crate::futures::FutureExt;
Box::pin(async move {
#(#body)*
Expand All @@ -571,7 +571,7 @@ pub fn message_handler(
#mio: &'a mut MessageIo<Self>,
#meta: &'a mut BlockMeta,
#pmt: Pmt,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::anyhow::Result<Pmt>> + 'a>> {
) -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::runtime::Result<Pmt>> + 'a>> {
use crate::futures::FutureExt;
Box::pin(async move {
#(#body)*
Expand Down Expand Up @@ -648,7 +648,7 @@ pub fn message_handler_external(
#mio: &'a mut MessageIo<Self>,
#meta: &'a mut BlockMeta,
#pmt: Pmt,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = futuresdr::anyhow::Result<Pmt>> + Send + 'a>> {
) -> std::pin::Pin<Box<dyn std::future::Future<Output = futuresdr::runtime::Result<Pmt>> + Send + 'a>> {
use futuresdr::futures::FutureExt;
Box::pin(async move {
#(#body)*
Expand All @@ -661,7 +661,7 @@ pub fn message_handler_external(
#mio: &'a mut MessageIo<Self>,
#meta: &'a mut BlockMeta,
#pmt: Pmt,
) -> std::pin::Pin<Box<dyn std::future::Future<Output = futuresdr::anyhow::Result<Pmt>> + 'a>> {
) -> std::pin::Pin<Box<dyn std::future::Future<Output = futuresdr::runtime::Result<Pmt>> + 'a>> {
use futuresdr::futures::FutureExt;
Box::pin(async move {
#(#body)*
Expand Down
1 change: 1 addition & 0 deletions examples/adsb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ soapy = ["futuresdr/soapy"]

[dependencies]
adsb_deku = "0.7"
anyhow = "1.0"
clap = { version = "4", features = ["derive"] }
futuresdr = { path = "../..", features = ["seify"] }
serde = { version = "1", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/adsb/src/bin/listen_adsb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use adsb_demod::Demodulator;
use adsb_demod::PreambleDetector;
use adsb_demod::Tracker;
use adsb_demod::DEMOD_SAMPLE_RATE;
use anyhow::Result;
use clap::command;
use clap::Parser;
use futuresdr::anyhow::Result;
use futuresdr::blocks::seify::SourceBuilder;
use futuresdr::blocks::Apply;
use futuresdr::blocks::FileSource;
Expand Down
4 changes: 2 additions & 2 deletions examples/adsb/src/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::DemodPacket;
use adsb_deku::deku::DekuContainerRead;
use futuresdr::anyhow::bail;
use futuresdr::anyhow::Result;
use anyhow::bail;
use futuresdr::macros::async_trait;
use futuresdr::macros::message_handler;
use futuresdr::runtime::BlockMeta;
Expand All @@ -10,6 +9,7 @@ use futuresdr::runtime::Kernel;
use futuresdr::runtime::MessageIo;
use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::Pmt;
use futuresdr::runtime::Result;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::TypedBlock;
use futuresdr::runtime::WorkIo;
Expand Down
2 changes: 1 addition & 1 deletion examples/adsb/src/demodulator.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use crate::N_SAMPLES_PER_HALF_SYM;
use crate::SYMBOL_ONE_TAPS;
use crate::SYMBOL_ZERO_TAPS;
use futuresdr::anyhow::Result;
use futuresdr::macros::async_trait;
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::Result;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::Tag;
Expand Down
2 changes: 1 addition & 1 deletion examples/adsb/src/preamble_detector.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::N_SAMPLES_PER_HALF_SYM;
use futuresdr::anyhow::Result;
use futuresdr::macros::async_trait;
use futuresdr::runtime::BlockMeta;
use futuresdr::runtime::BlockMetaBuilder;
use futuresdr::runtime::Kernel;
use futuresdr::runtime::MessageIo;
use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::Result;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::Tag;
Expand Down
2 changes: 1 addition & 1 deletion examples/adsb/src/tracker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use futuresdr::anyhow::Result;
use futuresdr::async_io::Timer;
use futuresdr::macros::async_trait;
use futuresdr::macros::message_handler;
Expand All @@ -8,6 +7,7 @@ use futuresdr::runtime::Kernel;
use futuresdr::runtime::MessageIo;
use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::Pmt;
use futuresdr::runtime::Result;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::TypedBlock;
Expand Down
1 change: 1 addition & 0 deletions examples/android-hw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = "1.0"
futuresdr = { path = "../..", features = ["soapy"] }
jni = { version = "0.21" }
5 changes: 2 additions & 3 deletions examples/android-hw/src/fft_shift.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std::marker::PhantomData;

use futuresdr::anyhow::Result;
use anyhow::Result;
use futuresdr::macros::async_trait;
use futuresdr::runtime::BlockMeta;
use futuresdr::runtime::BlockMetaBuilder;
Expand All @@ -11,6 +9,7 @@ use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::TypedBlock;
use futuresdr::runtime::WorkIo;
use std::marker::PhantomData;

pub struct FftShift<T> {
_p: PhantomData<T>,
Expand Down
6 changes: 2 additions & 4 deletions examples/android-hw/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
mod fft_shift;
use anyhow::Result;
use fft_shift::FftShift;

use std::env;

use futuresdr::anyhow::Result;
use futuresdr::blocks::seify::SourceBuilder;
use futuresdr::blocks::Apply;
use futuresdr::blocks::Fft;
Expand All @@ -14,6 +11,7 @@ use futuresdr::num_complex::Complex32;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::info;
use std::env;

pub fn run_fg() -> Result<()> {
futuresdr::runtime::init();
Expand Down
2 changes: 1 addition & 1 deletion examples/android-hw/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use androidhw::run_fg;
use futuresdr::anyhow::Result;
use anyhow::Result;

fn main() -> Result<()> {
run_fg()?;
Expand Down
1 change: 1 addition & 0 deletions examples/android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = "1.0"
futuresdr = { path = "../..", features = ["vulkan"] }
jni = { version = "0.21" }
rand = "0.8"
7 changes: 3 additions & 4 deletions examples/android/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use std::iter::repeat_with;
use std::sync::Arc;

use futuresdr::anyhow::Result;
use anyhow::Result;
use futuresdr::blocks::Copy;
use futuresdr::blocks::VectorSink;
use futuresdr::blocks::VectorSinkBuilder;
Expand All @@ -13,6 +10,8 @@ use futuresdr::runtime::buffer::vulkan::H2D;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use futuresdr::tracing::info;
use std::iter::repeat_with;
use std::sync::Arc;

pub fn run_fg() -> Result<()> {
let mut fg = Flowgraph::new();
Expand Down
2 changes: 1 addition & 1 deletion examples/android/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use androidfs::run_fg;
use futuresdr::anyhow::Result;
use anyhow::Result;

fn main() -> Result<()> {
run_fg()?;
Expand Down
4 changes: 2 additions & 2 deletions examples/audio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ name = "play-selectable-tone"
path = "play_selectable_tone.rs"

[dependencies]
futuresdr = { path = "../..", features = ["audio", "zeromq"] }
anyhow = "1.0"
clap = { version = "4", features = ["derive"] }

futuresdr = { path = "../..", features = ["audio", "zeromq"] }
2 changes: 1 addition & 1 deletion examples/audio/play_file.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futuresdr::anyhow::Result;
use anyhow::Result;
use futuresdr::blocks::audio::AudioSink;
use futuresdr::blocks::audio::FileSource;
use futuresdr::runtime::Flowgraph;
Expand Down
2 changes: 1 addition & 1 deletion examples/audio/play_selectable_tone.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Result;
use clap::Parser;
use futuresdr::anyhow::Result;
use futuresdr::async_io;
use futuresdr::blocks::audio::AudioSink;
use futuresdr::blocks::Selector;
Expand Down
2 changes: 1 addition & 1 deletion examples/audio/play_stereo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futuresdr::anyhow::Result;
use anyhow::Result;
use futuresdr::blocks::audio::AudioSink;
use futuresdr::blocks::audio::FileSource;
use futuresdr::blocks::ApplyNM;
Expand Down
2 changes: 1 addition & 1 deletion examples/audio/play_tone.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futuresdr::anyhow::Result;
use anyhow::Result;
use futuresdr::blocks::audio::AudioSink;
use futuresdr::blocks::SignalSourceBuilder;
use futuresdr::runtime::Flowgraph;
Expand Down
2 changes: 1 addition & 1 deletion examples/ctrlport-demo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futuresdr::anyhow::Result;
use anyhow::Result;
use futuresdr::macros::async_trait;
use futuresdr::macros::message_handler;
use futuresdr::runtime::BlockMeta;
Expand Down
1 change: 1 addition & 0 deletions examples/custom-routes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ edition = "2021"
[workspace]

[dependencies]
anyhow = "1.0"
axum = "0.7"
futuresdr = { path = "../../" }
9 changes: 4 additions & 5 deletions examples/custom-routes/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
use anyhow::Result;
use axum::extract::State;
use axum::response::Html;
use axum::routing::get;
use axum::Router;
use std::sync::Arc;
use std::sync::Mutex;
use std::time;

use futuresdr::anyhow::Result;
use futuresdr::blocks::MessageSourceBuilder;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Pmt;
use futuresdr::runtime::Runtime;
use futuresdr::runtime::RuntimeHandle;
use std::sync::Arc;
use std::sync::Mutex;
use std::time;

#[derive(Clone)]
struct WebState {
Expand Down
1 change: 1 addition & 0 deletions examples/cw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = "1.0"
futuresdr = { path = "../..", features = ["audio"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
Expand Down
6 changes: 3 additions & 3 deletions examples/cw/src/bin/tx.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use futuresdr::anyhow::Result;
use anyhow::Result;

#[cfg(not(target_arch = "wasm32"))]
mod foo {
use anyhow::Result;
use clap::Parser;
use futuresdr::anyhow::Result;
use futuresdr::async_io::block_on;

use cw::run_fg;
Expand All @@ -26,7 +26,7 @@ mod foo {

#[cfg(target_arch = "wasm32")]
mod foo {
use futuresdr::anyhow::Result;
use anyhow::Result;
use leptos::html::Input;
use leptos::*;

Expand Down
2 changes: 1 addition & 1 deletion examples/cw/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use futuresdr::anyhow::Result;
use futuresdr::blocks::audio::AudioSink;
use futuresdr::blocks::ApplyIntoIter;
use futuresdr::blocks::Combine;
use futuresdr::blocks::SignalSourceBuilder;
use futuresdr::blocks::VectorSource;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Result;
use futuresdr::runtime::Runtime;
use std::fmt;

Expand Down
3 changes: 2 additions & 1 deletion examples/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ name = "tag_debug"
path = "tag_debug.rs"

[dependencies]
futuresdr = { path = "../..", features = ['flow_scheduler', 'tpb_scheduler']}
anyhow = "1.0"
clap = { version = "4", features = ["derive"] }
futuresdr = { path = "../..", features = ['flow_scheduler', 'tpb_scheduler']}

6 changes: 2 additions & 4 deletions examples/debug/oscillators.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use std::time;

use futuresdr::anyhow::Result;
use futuresdr::blocks::FileSink;
use futuresdr::blocks::Head;
use futuresdr::blocks::SignalSourceBuilder;
use futuresdr::macros::connect;
use futuresdr::num_complex::Complex32;
use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Runtime;
use std::time;

fn main() -> Result<()> {
fn main() -> anyhow::Result<()> {
let sample_rate = 48_000.0;
let freq = 4800.0;
let items = 100_000_000;
Expand Down
3 changes: 1 addition & 2 deletions examples/debug/panic.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use clap::Parser;
use clap::ValueEnum;

use futuresdr::anyhow::Result;
use futuresdr::macros::async_trait;
use futuresdr::macros::connect;
use futuresdr::runtime::scheduler;
Expand All @@ -11,6 +9,7 @@ use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Kernel;
use futuresdr::runtime::MessageIo;
use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::Result;
use futuresdr::runtime::Runtime;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
Expand Down
4 changes: 2 additions & 2 deletions examples/debug/tag_debug.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use futuresdr::anyhow::Result;
use futuresdr::blocks::TagDebug;
use futuresdr::blocks::VectorSource;
use futuresdr::macros::async_trait;
Expand All @@ -8,14 +7,15 @@ use futuresdr::runtime::Flowgraph;
use futuresdr::runtime::Kernel;
use futuresdr::runtime::MessageIo;
use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::Result;
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<()> {
fn main() -> anyhow::Result<()> {
let mut fg = Flowgraph::new();

let n_items = 10000;
Expand Down
1 change: 1 addition & 0 deletions examples/egui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ aaronia_http = ["futuresdr/aaronia_http"]
soapy = ["futuresdr/soapy"]

[dependencies]
anyhow ="1.0"
eframe = "0.29"
futuresdr = { path = "../..", features = ["seify"] }
futuresdr-remote = { path = "../../crates/remote/" }
Expand Down
Loading

0 comments on commit 9d8b741

Please sign in to comment.