diff --git a/.clippy.toml b/.clippy.toml new file mode 100644 index 0000000000000..66d55301def81 --- /dev/null +++ b/.clippy.toml @@ -0,0 +1,7 @@ +too-many-arguments-threshold = 20 +disallowed-methods = [ + # unbounded channels are for expert use only + { path = "tokio::sync::mpsc::unbounded", reason = "use a bounded channel instead" }, + { path = "futures::channel::mpsc::unbounded", reason = "use a bounded channel instead" }, + { path = "futures_channel::mpsc::unbounded", reason = "use a bounded channel instead" }, +] diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0790b76c1e883..cf0d73cde19fc 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -93,7 +93,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: clippy - args: --all -- -D clippy::all -D warnings + args: --all -- -D clippy::all -D warnings -D clippy::disallowed_method rustfmt: name: rustfmt diff --git a/fastpay_core/clippy.toml b/fastpay_core/clippy.toml deleted file mode 100644 index da879ebe9c749..0000000000000 --- a/fastpay_core/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -too-many-arguments-threshold = 20 \ No newline at end of file diff --git a/fastpay_core/src/downloader.rs b/fastpay_core/src/downloader.rs index 4c970cda8dcda..88c1dc21c040a 100644 --- a/fastpay_core/src/downloader.rs +++ b/fastpay_core/src/downloader.rs @@ -19,9 +19,9 @@ pub struct Downloader { /// Status of previous downloads, indexed by key. downloads: BTreeMap>, /// Command stream of the main handler. - command_receiver: mpsc::UnboundedReceiver>, + command_receiver: mpsc::Receiver>, /// How to send commands to the main handler. - command_sender: mpsc::UnboundedSender>, + command_sender: mpsc::Sender>, } /// The underlying data-fetching mechanism to be provided by the user. @@ -36,7 +36,7 @@ pub trait Requester { /// Channel for using code to send requests and stop the downloader task. #[derive(Clone)] -pub struct DownloadHandle(mpsc::UnboundedSender>); +pub struct DownloadHandle(mpsc::Sender>); /// A command send to the downloader task. enum DownloadCommand { @@ -100,7 +100,7 @@ where where I: IntoIterator, { - let (command_sender, command_receiver) = mpsc::unbounded(); + let (command_sender, command_receiver) = mpsc::channel(1024); let mut downloads = BTreeMap::new(); for (key, value) in known_values { downloads.insert(key, DownloadStatus::Ready(value));