1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//! Macros for network access.

use crate::{Result, Tool, ToolInfo, Value, ValueType};

pub struct Download;

impl Tool for Download {
    fn info(&self) -> ToolInfo<'static> {
        ToolInfo {
            identifier: "download",
            description: "Fetch a network resource.",
            group: "network",
            inputs: vec![ValueType::String],
        }
    }

    fn run(&self, argument: &Value) -> Result<Value> {
        let argument = argument.as_string()?;
        let output = reqwest::blocking::get(argument)?.text()?;

        Ok(Value::String(output))
    }
}