1use crate::backend;
4use crate::core::Raw;
5
6#[derive(Clone, Copy, Debug)]
11pub struct Md5State {
12 raw: Raw,
13}
14
15impl Default for Md5State {
16 #[inline]
17 fn default() -> Self {
18 Self::new()
19 }
20}
21
22impl Md5State {
23 #[inline]
25 pub const fn new() -> Self {
26 Self { raw: Raw::new() }
27 }
28
29 #[inline]
31 pub fn update(&mut self, input: &[u8]) {
32 self.raw.update_opt(input);
33 }
34
35 #[inline]
37 #[must_use]
38 pub fn finalize(&self) -> [u8; 16] {
39 self.raw.digest_snapshot(backend::compress_block)
40 }
41
42 #[inline]
44 pub fn reset(&mut self) {
45 self.raw.reset();
46 }
47
48 #[inline]
50 pub const fn bytes_hashed(&self) -> u64 {
51 self.raw.count
52 }
53
54 #[inline]
56 pub const fn is_empty(&self) -> bool {
57 self.raw.count == 0
58 }
59}