[][src]Struct iocutil::contenthash::ContentHash

pub struct ContentHash {
    pub sha256: SampleHash,
    pub sha1: SampleHash,
    pub md5: SampleHash,
}

Fields

sha256: SampleHashsha1: SampleHashmd5: SampleHash

Methods

impl ContentHash[src]

pub fn new(
    sha256: impl TryInto<SampleHash>,
    sha1: impl TryInto<SampleHash>,
    md5: impl TryInto<SampleHash>
) -> Result<Self, Error>
[src]

create new object manually (not recommened)

Example

use iocutil::prelude::*;
let x = ContentHash::new(
    "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "d41d8cd98f00b204e9800998ecf8427e"
).unwrap();
assert_eq!(x, ContentHash::default());

let y = ContentHash::new("a", "b", "c");
assert!(y.is_err());

let z = ContentHash::new(
    "da39a3ee5e6b4b0d3255bfef95601890afd80709",
    "d41d8cd98f00b204e9800998ecf8427e",
    "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
);
assert!(z.is_err());

pub fn of_file(path: impl AsRef<Path>) -> Result<Self, Error>[src]

content hash of file

Example

use iocutil::prelude::*;

let ch = ContentHash::of_file(r"./Cargo.toml").expect("failed to calc hash");
println!("{:?}", ch);

Trait Implementations

impl Into<ContentHash> for FileReport[src]

impl IntoIterator for ContentHash[src]

type Item = SampleHash

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Example

use iocutil::prelude::*;

let s = ContentHash::of_file("./Cargo.toml").unwrap();
let set: std::collections::HashSet<SampleHash> = s.into_iter().collect();

assert_eq!(set.len(), 3);

impl Clone for ContentHash[src]

impl Default for ContentHash[src]

fn default() -> Self[src]

return ContentHash of empty bytes as default

Example

use iocutil::prelude::*;

let c = ContentHash::default();
assert_eq!(c.sha256.as_ref(), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
assert_eq!(c.sha1.as_ref(), "da39a3ee5e6b4b0d3255bfef95601890afd80709");
assert_eq!(c.md5.as_ref(), "d41d8cd98f00b204e9800998ecf8427e");

impl Eq for ContentHash[src]

impl PartialEq<ContentHash> for ContentHash[src]

impl Debug for ContentHash[src]

impl Hash for ContentHash[src]

impl StructuralPartialEq for ContentHash[src]

impl StructuralEq for ContentHash[src]

Auto Trait Implementations

Blanket Implementations

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

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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