fn globally(name: &str, spec: &str, config: &Config) -> Result<(), Error> {
    use {
        library::{database::core, package::Dir},
        std::{
            io::{Read, Write},
            net::TcpStream,
        },
    };

    let version = core()?.newest(name)?;

    let server = config.servers[0];
    let request = format!("{}:{}\n{}\n", name, version, spec);

    let mut stream = TcpStream::connect(server)?;
    stream.write_all(request.as_bytes())?;

    let mut data = Vec::new();
    stream.read_to_end(&mut data)?;

    // package was found
    if data[0] == 1 {
        let dir = temp_dir()?;

        // remove indicator byte
        data.remove(0);
        let build = Dir { data };

        build.decode(dir.path())?;

        install_script(dir.path())?;

        Ok(())
    } else {
        Err(Error::PkgNotFound)
    }
}
/// installs the build in a package called `name` with specification `spec`
/// # Errors
/// Returns `Error::Io` if opening the temporary directory fails.
/// Returns `Error::Unpack` if unpacking the archive to the temporary directory fails.
installs the build in a package called `name` with specification `spec`
installs the build in a package called ` name ` with specification ` spec `
fn globally(name: &str, spec: &str, config: &Config) -> Result<(), Error> {
    use {
        library::{database::core, package::Dir},
        std::{
            io::{Read, Write},
            net::TcpStream,
        },
    };
    let version = core()?.newest(name)?;
    let server = config.servers[0];
    let request = format!("{}:{}\n{}\n", name, version, spec);
    let mut stream = TcpStream::connect(server)?;
    stream.write_all(request.as_bytes())?;
    let mut data = Vec::new();
    stream.read_to_end(&mut data)?;
    // package was found
    if data[0] == 1 {
        let dir = temp_dir()?;
        // remove indicator byte
        data.remove(0);
        let build = Dir { data };
        build.decode(dir.path())?;
        install_script(dir.path())?;
        Ok(())
    } else {
        Err(Error::PkgNotFound)
    }
}
fn globally ( name : & str , spec : & str , config : & Config ) -> Result < ( ) , Error > { use { library :: { database :: core , package :: Dir } , std :: { io :: { Read , Write } , net :: TcpStream , } , } ; let version = core ( ) ? . newest ( name ) ? ; let server = config . servers [ 0 ] ; let request = format ! ( " \n \n " name version spec ) ; let mut stream = TcpStream :: connect ( server ) ? ; stream . write_all ( request . as_bytes ( ) ) ? ; let mut data = Vec :: new ( ) ; stream . read_to_end ( & mut data ) ? ; // package was found if data [ 0 ] == 1 { let dir = temp_dir ( ) ? ; // remove indicator byte data . remove ( 0 ) ; let build = Dir { data } ; build . decode ( dir . path ( ) ) ? ; install_script ( dir . path ( ) ) ? ; Ok ( ( ) ) } else { Err ( Error :: PkgNotFound ) } }
installs the build in a package called `name` with specification `spec`
installs the build in a package called ` name ` with specification ` spec `
name
&str
spec
&str
config
&Config
name
&str
spec
&str
config
&Config
errors
Returns `Error::Io` if opening the temporary directory fails.
Returns `Error::Unpack` if unpacking the archive to the temporary directory fails.
Returns ` Error :: Io ` if opening the temporary directory fails . Returns ` Error :: Unpack ` if unpacking the archive to the temporary directory fails .