Artifact Content
Not logged in

Artifact 7cc1f7454c1a374b2df44206b2abcea1e7761930:

Unrecognized artifact
// Copyright 2016 limited.
// This SAFE Network Software is licensed to you under (1) the Commercial License,
// version 1.0 or later, or (2) The General Public License (GPL), version 3, depending on which
// licence you accepted on initial access to the Software (the "Licences").
// By contributing code to the SAFE Network Software, or to this project generally, you agree to be
// bound by the terms of the MaidSafe Contributor Agreement.  This, along with the Licenses can be
// found in the root directory of this project at LICENSE, COPYING and CONTRIBUTOR.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
// Please review the Licences for the specific language governing permissions and limitations
// relating to use of the SAFE Network Software.

//! This build script downloads some diagrams from Cacoo and places them into
//! the docs directory, so they can be linked or embedded in the docs.
//! Currently the diagrams are only downloaded when cargo is run with
//! the `generate-diagrams` feature enabled.


#[cfg(feature = "generate-diagrams")]
extern crate hyper;

#[cfg(feature = "generate-diagrams")]
mod generate_diagrams {
    use hyper::Client;
    use hyper::client::IntoUrl;
    use std::fs::{self, File};
    use std::io;
    use std::path::{Path, PathBuf};

    pub fn download_image<U: IntoUrl>(name: &str, src: U) {
        download(src, image_path(name))

    fn download<U: IntoUrl, P: AsRef<Path>>(src: U, dst: P) {
        let client = Client::new();
        let mut res = client.get(src).send().unwrap();

        if let Some(dir) = dst.as_ref().parent() {

        let mut file = File::create(dst).unwrap();
        io::copy(&mut res, &mut file).unwrap();

    fn image_path(name: &str) -> PathBuf {
        let mut path = PathBuf::from("target/doc/safe_vault");

// Only generate the diagrams when "generate-diagrams" feature is enabled.
// TODO: instead of this feature, detect that cargo is run in the "doc" profile.
#[cfg(feature = "generate-diagrams")]
fn main() {
    // List all diagram names and URLs to download them from.

#[cfg(not(feature = "generate-diagrams"))]
fn main() {}