Crates.io | sleep-parser |
lib.rs | sleep-parser |
version | 0.8.0 |
source | src |
created_at | 2018-03-22 01:37:05.436885 |
updated_at | 2018-12-28 12:43:01.420192 |
description | Parse Dat protocol SLEEP files |
homepage | |
repository | https://github.com/datrs/sleep-parser |
max_upload_size | |
id | 56825 |
size | 47,666 |
Parse Dat protocol SLEEP files.
extern crate sleep_parser as sleep_parser;
use sleep_parser::{FileType, HashType, Header};
use std::fs::File;
use std::io::{BufRead, BufReader};
let file = File::open("tests/fixtures/content.bitfield").unwrap();
let mut reader = BufReader::with_capacity(32, file);
let buffer = reader.fill_buf().unwrap();
let header = Header::from_vec(&buffer).unwrap();
assert!(header.is_bitfield());
<32 byte header>
<4 byte magic string: 0x05025702>
<1 byte version number: 0>
<2 byte entry size: 40>
<1 byte algorithm name length prefix: 7>
<7 byte algorithm name: BLAKE2b>
<17 zeroes>
<40 byte entries>
<32 byte BLAKE2b hash>
<8 byte Uint64BE children leaf byte length>
$ cargo add sleep-parser
MIT or Apache-2.0