Shorten Pin<Box to BoxFuture
This commit is contained in:
parent
1b79b66cc3
commit
a001bb8c97
6 changed files with 19 additions and 27 deletions
|
|
@ -1,7 +1,6 @@
|
|||
use std::{
|
||||
cmp::Reverse,
|
||||
net::SocketAddr,
|
||||
pin::Pin,
|
||||
str::FromStr,
|
||||
sync::{
|
||||
atomic::{AtomicU16, Ordering},
|
||||
|
|
@ -24,7 +23,9 @@ use anyhow::{bail, Context};
|
|||
use backoff::{backoff::Backoff, ExponentialBackoffBuilder};
|
||||
use bencode::ByteString;
|
||||
use dashmap::DashMap;
|
||||
use futures::{stream::FuturesUnordered, Future, FutureExt, Stream, StreamExt, TryFutureExt};
|
||||
use futures::{
|
||||
future::BoxFuture, stream::FuturesUnordered, FutureExt, Stream, StreamExt, TryFutureExt,
|
||||
};
|
||||
|
||||
use leaky_bucket::RateLimiter;
|
||||
use librqbit_core::{
|
||||
|
|
@ -1147,9 +1148,7 @@ impl DhtState {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn with_config(
|
||||
mut config: DhtConfig,
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<Arc<Self>>> + Send>> {
|
||||
pub fn with_config(mut config: DhtConfig) -> BoxFuture<'static, anyhow::Result<Arc<Self>>> {
|
||||
async move {
|
||||
let socket = match config.listen_addr {
|
||||
Some(addr) => UdpSocket::bind(addr)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// TODO: this now stores only the routing table, but we also need AT LEAST the same socket address...
|
||||
|
||||
use futures::{Future, FutureExt};
|
||||
use futures::future::BoxFuture;
|
||||
use futures::FutureExt;
|
||||
use librqbit_core::directories::get_configuration_directory;
|
||||
use librqbit_core::spawn_utils::spawn_with_cancel;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
|
@ -8,7 +9,6 @@ use std::fs::OpenOptions;
|
|||
use std::io::{BufReader, BufWriter};
|
||||
use std::net::SocketAddr;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::pin::Pin;
|
||||
use std::time::Duration;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ impl PersistentDht {
|
|||
pub fn create(
|
||||
config: Option<PersistentDhtConfig>,
|
||||
cancellation_token: Option<CancellationToken>,
|
||||
) -> Pin<Box<dyn Future<Output = anyhow::Result<Dht>> + Send>> {
|
||||
) -> BoxFuture<'static, anyhow::Result<Dht>> {
|
||||
async move {
|
||||
let mut config = config.unwrap_or_default();
|
||||
let config_filename = match config.config_filename.take() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue