stable tokio version 0.2
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -8,6 +8,7 @@ mod watch;
|
||||
use ace::App;
|
||||
use config::{Config, Hosts, Invalid, Parser};
|
||||
use dirs;
|
||||
use futures::prelude::*;
|
||||
use lib::*;
|
||||
use regex::Regex;
|
||||
use std::{
|
||||
@@ -20,8 +21,7 @@ use std::{
|
||||
use tokio::{
|
||||
io::{Error, ErrorKind, Result},
|
||||
net::UdpSocket,
|
||||
prelude::*,
|
||||
timer::Timeout,
|
||||
time::timeout,
|
||||
};
|
||||
use watch::Watch;
|
||||
|
||||
@@ -287,15 +287,12 @@ async fn proxy(buf: &[u8]) -> Result<Vec<u8>> {
|
||||
for addr in proxy.iter() {
|
||||
let mut socket = UdpSocket::bind(("0.0.0.0", 0)).await?;
|
||||
|
||||
let data: Result<Vec<u8>> = Timeout::new(
|
||||
async {
|
||||
socket.send_to(&buf, addr).await?;
|
||||
let mut res = [0; 512];
|
||||
let len = socket.recv(&mut res).await?;
|
||||
Ok(res[..len].to_vec())
|
||||
},
|
||||
Duration::from_millis(unsafe { TIMEOUT }),
|
||||
)
|
||||
let data: Result<Vec<u8>> = timeout(Duration::from_millis(unsafe { TIMEOUT }), async {
|
||||
socket.send_to(&buf, addr).await?;
|
||||
let mut res = [0; 512];
|
||||
let len = socket.recv(&mut res).await?;
|
||||
Ok(res[..len].to_vec())
|
||||
})
|
||||
.await?;
|
||||
|
||||
match data {
|
||||
|
||||
10
src/watch.rs
10
src/watch.rs
@@ -1,11 +1,15 @@
|
||||
use futures::ready;
|
||||
use futures::{prelude::*, ready};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
time::{Duration, SystemTime},
|
||||
};
|
||||
use tokio::{fs::File, io::Result, prelude::*, timer::Interval};
|
||||
use tokio::{
|
||||
fs::File,
|
||||
io::Result,
|
||||
time::{interval, Interval},
|
||||
};
|
||||
|
||||
pub struct Watch {
|
||||
path: PathBuf,
|
||||
@@ -21,7 +25,7 @@ impl Watch {
|
||||
path: path.clone(),
|
||||
state: None,
|
||||
modified: Self::modified(path).await,
|
||||
timer: Interval::new_interval(Duration::from_millis(duration)),
|
||||
timer: interval(Duration::from_millis(duration)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user