sha2-derive

Crates.iosha2-derive
lib.rssha2-derive
version0.1.2
sourcesrc
created_at2022-03-31 15:21:17.085703
updated_at2022-03-31 15:37:06.186628
descriptionA crate exporting a derivable `Hashable` trait that works with `sha2`.
homepage
repositoryhttps://github.com/Mubelotix/sha2-derive
max_upload_size
id559657
size7,610
(Mubelotix)

documentation

README

sha2-derive

This crate provides a simple Hashable trait that can be derived easily. As of now, the derive macro only works on structs.

Example

use sha2_derive::*;

#[derive(Hashable)]
struct User {
    username: String,
    age: u8,
    timestamps: Vec<u64>,
}

fn main() {
    let user = User {
        username: String::from("Mubelotix"),
        age: 42,
        timestamps: vec![1, 2, 3],
    };

    let hash = user.hash();
}

Implementing Hashable on a custom type

struct CustomType {
   // fields
}

impl Hashable for CustomType {
    fn update_hasher(&self, hasher: &mut impl sha2::Digest) {
        todo!()
    }
}

License: MIT

Commit count: 18

cargo fmt