blob: fc86fb37adb3017448f4554eb187a49827a3caa7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
extern crate reqwest;
use std::thread;
use std::time::Duration;
use utils;
use super::rlua::prelude::*;
use self::LuaError::RuntimeError;
pub fn download(_: &Lua, url: String) -> Result<String, LuaError> {
match utils::download(1024, &url) {
Some(v) => Ok(v),
None => Err(RuntimeError(format!("Failed to download {}", url))),
}
}
pub fn sleep(_: &Lua, dur: u64) -> Result<(), LuaError> {
thread::sleep(Duration::from_millis(dur));
Ok(())
}
|