/// Creates a new Holmes value holding raw data.
Creates a new Holmes value holding raw data.
Creates a new Holmes value holding raw data .
pub fn new(val: Vec<u8>) -> Arc<Self> {
            use sha2::*;
            use std::fs::File;
            use std::io::Write;
            use rustc_serialize::hex::ToHex;
            let mut path = match ::std::env::var("HOLMES_STORAGE") {
                Ok(dir) => ::std::path::PathBuf::from(dir),
                _ => {
                    let mut path = ::std::env::home_dir().unwrap();
                    path.push(".holmes");
                    path
                }
            };
            let mut hasher = Sha256::default();
            hasher.input(&val);
            let fname = hasher.result().to_hex();
            path.push(fname.clone());
            {
                let mut file = File::create(path.clone()).unwrap();
                file.write_all(&val).unwrap();
            }
            let file = File::open(path.clone()).unwrap();
            Arc::new(LargeBytes {
                fd: Rc::new(file),
                hash: fname,
            })
        }
pub fn new ( val : Vec < u8 > ) -> Arc < Self > { use sha2 :: * ; use std :: fs :: File ; use std :: io :: Write ; use rustc_serialize :: hex :: ToHex ; let mut path = match :: std :: env :: var ( " " ) { Ok ( dir ) => :: std :: path :: PathBuf :: from ( dir ) , _ => { let mut path = :: std :: env :: home_dir ( ) . unwrap ( ) ; path . push ( " " ) ; path } } ; let mut hasher = Sha256 :: default ( ) ; hasher . input ( & val ) ; let fname = hasher . result ( ) . to_hex ( ) ; path . push ( fname . clone ( ) ) ; { let mut file = File :: create ( path . clone ( ) ) . unwrap ( ) ; file . write_all ( & val ) . unwrap ( ) ; } let file = File :: open ( path . clone ( ) ) . unwrap ( ) ; Arc :: new ( LargeBytes { fd : Rc :: new ( file ) , hash : fname , } ) }
Creates a new Holmes value holding raw data.
Creates a new Holmes value holding raw data .
val
Vec<u8>