pub fn download_script(url: String) -> Result<Script, String> {
        // Get the install directory, `~/.rapture/`
        PathManager::make_install_dir()?;

        // Here we push `rapture_download.txt` onto the path,
        // so `download_file` will download to `~/.rapture/rapture_download.txt`.
        // I chose this file location because it doesnt get in the way of packages,
        // but it stays in the rapture install directory.
        let mut download_pathbuf = PathBuf::new();
        download_pathbuf.push(PathManager::install_dir());
        download_pathbuf.push("rapture_download.txt");
        let download_path = path_to_string(download_pathbuf);

        // Download the file
        Self::download_file(url, download_path.clone())?;

        // Open the file for reading, we want to create a script object
        // with the contents of the downloaded script.
        let mut downloaded_file = File::open(download_path);
        match &mut downloaded_file {
            Ok(f) => {
                // Success!
                // Read the file as valid UTF-8
                let mut contents = String::new();
                f.read_to_string(&mut contents).unwrap();
                Ok(Script::new(contents))
            },
            // Reading the file returned an error
            Err(_) => Err("Could not open downloaded script".to_string())
        }
    }
/// This function takes a url to a rapture script, and calls `download_file` 
/// with the url and the proper download file output location. After 
/// downloading, we read the script from the output file and return it.
/// 
/// See script::Script for more information on how the script object works.
This function takes a url to a rapture script, and calls `download_file`
with the url and the proper download file output location. After
downloading, we read the script from the output file and return it.

See script::Script for more information on how the script object works.
This function takes a url to a rapture script and calls ` download_file ` with the url and the proper download file output location . After downloading we read the script from the output file and return it . See script :: Script for more information on how the script object works .
pub fn download_script(url: String) -> Result<Script, String> {
        // Get the install directory, `~/.rapture/`
        PathManager::make_install_dir()?;
        // Here we push `rapture_download.txt` onto the path,
        // so `download_file` will download to `~/.rapture/rapture_download.txt`.
        // I chose this file location because it doesnt get in the way of packages,
        // but it stays in the rapture install directory.
        let mut download_pathbuf = PathBuf::new();
        download_pathbuf.push(PathManager::install_dir());
        download_pathbuf.push("rapture_download.txt");
        let download_path = path_to_string(download_pathbuf);
        // Download the file
        Self::download_file(url, download_path.clone())?;
        // Open the file for reading, we want to create a script object
        // with the contents of the downloaded script.
        let mut downloaded_file = File::open(download_path);
        match &mut downloaded_file {
            Ok(f) => {
                // Success!
                // Read the file as valid UTF-8
                let mut contents = String::new();
                f.read_to_string(&mut contents).unwrap();
                Ok(Script::new(contents))
            },
            // Reading the file returned an error
            Err(_) => Err("Could not open downloaded script".to_string())
        }
    }
pub fn download_script ( url : String ) -> Result < Script , String > { // Get the install directory, `~/.rapture/` PathManager :: make_install_dir ( ) ? ; // Here we push `rapture_download.txt` onto the path, // so `download_file` will download to `~/.rapture/rapture_download.txt`. // I chose this file location because it doesnt get in the way of packages, // but it stays in the rapture install directory. let mut download_pathbuf = PathBuf :: new ( ) ; download_pathbuf . push ( PathManager :: install_dir ( ) ) ; download_pathbuf . push ( " " ) ; let download_path = path_to_string ( download_pathbuf ) ; // Download the file Self :: download_file ( url , download_path . clone ( ) ) ? ; // Open the file for reading, we want to create a script object // with the contents of the downloaded script. let mut downloaded_file = File :: open ( download_path ) ; match & mut downloaded_file { Ok ( f ) => { // Success! // Read the file as valid UTF-8 let mut contents = String :: new ( ) ; f . read_to_string ( & mut contents ) . unwrap ( ) ; Ok ( Script :: new ( contents ) ) } , // Reading the file returned an error Err ( _ ) => Err ( " " . to_string ( ) ) } }
This function takes a url to a rapture script, and calls `download_file`
with the url and the proper download file output location.
This function takes a url to a rapture script and calls ` download_file ` with the url and the proper download file output location .
url
String
url
String