Struct libwgetj::DownloadConfig [] [src]

pub struct DownloadConfig {
    // some fields omitted
}

The Java download configuration. The download function will read from this configuration and build a url specific to the configuration.

Defaults

  • Package: JDK
  • Version: 8
  • Point Release: Latest for 8
  • OS: Linux
  • CPU Arch: 64-bit
  • Archive Type: .tar.gz
  • Download Directory: None
  • Dry Run: false

Methods

impl DownloadConfig
[src]

fn new() -> DownloadConfig

Create a new download configuration with some defaults.

Examples

use libwgetj::DownloadConfig;

let mut cfg = DownloadConfig::new();

fn package(&mut self, pkg: Package) -> &mut DownloadConfig

Set the package type.

Examples

use libwgetj::DownloadConfig;
use libwgetj::Package::*;

let mut cfg = DownloadConfig::new();
cfg.package(JRE);

fn version(&mut self, ver: Version) -> &mut DownloadConfig

Set the version.

Examples

use libwgetj::DownloadConfig;
use libwgetj::Version::*;

let mut cfg = DownloadConfig::new();
cfg.version(Seven);

fn point_release(&mut self, pr: u8) -> &mut DownloadConfig

Set the point release information.

Examples

use libwgetj::{DownloadConfig, latest};
use libwgetj::Version::*;

let mut cfg = DownloadConfig::new();
cfg.version(Seven).point_release(latest(Seven));

fn os(&mut self, os: OS) -> &mut DownloadConfig

Set the OS type.

Examples

use libwgetj::DownloadConfig;
use libwgetj::OS::*;

let mut cfg = DownloadConfig::new();
cfg.os(Windows);

fn arch(&mut self, arch: Arch) -> &mut DownloadConfig

Set the architecture (32 or 64-bit).

Examples

use libwgetj::DownloadConfig;
use libwgetj::Arch::*;

let mut cfg = DownloadConfig::new();
cfg.arch(I586);

fn archive(&mut self, archive: Archive) -> &mut DownloadConfig

Set the archive type.

Examples

use libwgetj::DownloadConfig;
use libwgetj::Archive::*;

let mut cfg = DownloadConfig::new();
cfg.archive(EXE);

fn dir(&mut self, path: Option<PathBuf>) -> &mut DownloadConfig

Set the target directory for the download.

Examples

use libwgetj::DownloadConfig;
use std::env;

let mut cfg = DownloadConfig::new();
cfg.dir(Some(env::temp_dir()));

fn dry_run(&mut self, enable: bool) -> &mut DownloadConfig

Set the dry run status.

Examples

use libwgetj::DownloadConfig;

let mut cfg = DownloadConfig::new();
cfg.dry_run(true);

fn check_config(&self) -> Result<()LibwgetjError>

Check the configuration for invalid combinations.

Examples

use libwgetj::DownloadConfig;
use libwgetj::Archive::*;
use libwgetj::OS::*;

let mut cfg = DownloadConfig::new();
// Invalid combination, Mac only has DMG downloads.
cfg.os(Mac).archive(TGZ).dry_run(true);
assert!(cfg.check_config().is_err());

fn download(&self) -> Result<i32LibwgetjError>

Execute the download.

Examples

use libwgetj::DownloadConfig;

let mut cfg = DownloadConfig::new();
assert!(cfg.dry_run(true).download().is_ok());