[][src]Struct sfv::Sfv

pub struct Sfv {
    pub files: BTreeMap<PathBuf, Vec<u8>>,
}

Fields

files: BTreeMap<PathBuf, Vec<u8>>

The file paths and their checksums/hashes

Implementations

impl Sfv[src]

pub fn new() -> Self[src]

Create a new, empty Sfv object

pub fn from_sfv<P: AsRef<Path>, S: AsRef<str>>(
    base_directory: P,
    sfv: S
) -> Result<Self, ()>
[src]

Convert a SFV file in string format to a Sfv object.

use sfv::Sfv;
use std::collections::BTreeMap;
use std::path::PathBuf;

let sfv_file = r#"
 ; This is a comment
  file_one.zip   c45ad668
  file_two.zip   7903b8e6
  file_three.zip e99a65fb
"#;

let sfv = Sfv::from_sfv("/test", sfv_file).unwrap();
assert_eq!(
    *sfv.files.get(&PathBuf::from("/test/file_one.zip")).unwrap(),
    vec![0xc4, 0x5a, 0xd6, 0x68]
)

pub fn add_file<P: AsRef<Path>, D: AsRef<[u8]>>(&mut self, path: P, data: D)[src]

Adds a file and checksum entry to the Sfv.

use sfv::Sfv;
use std::path::PathBuf;

let mut sfv = Sfv::new();
let path = PathBuf::from("/test.txt");
let checksum: Vec<u8> = vec![0x42, 0x42, 0x42, 0x42];
sfv.add_file(&path, &checksum);

assert_eq!(
    *sfv.files.get(&PathBuf::from("/test.txt")).unwrap(),
    vec![0x42, 0x42, 0x42, 0x42]
)

Trait Implementations

impl Clone for Sfv[src]

impl Debug for Sfv[src]

impl Default for Sfv[src]

impl Display for Sfv[src]

impl Eq for Sfv[src]

impl Ord for Sfv[src]

impl PartialEq<Sfv> for Sfv[src]

impl PartialOrd<Sfv> for Sfv[src]

impl StructuralEq for Sfv[src]

impl StructuralPartialEq for Sfv[src]

Auto Trait Implementations

impl RefUnwindSafe for Sfv

impl Send for Sfv

impl Sync for Sfv

impl Unpin for Sfv

impl UnwindSafe for Sfv

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.