crier

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs

commit c397a19282b8712e7e951c26d42ad9d48c148624
parent 9b733bcd472e147c7099452914b9d6435466f823
Author: lash <dev@holbrook.no>
Date:   Sat, 29 Jun 2024 22:48:06 +0100

Module selection, default test guard

Diffstat:
MCargo.lock | 101+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
MCargo.toml | 3+++
Msrc/lib.rs | 47+++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 149 insertions(+), 2 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -50,6 +50,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -84,11 +93,33 @@ name = "crier" version = "0.0.1" dependencies = [ "clap", + "digest", "feed-rs", + "rs_sha512", "tempfile", ] [[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] name = "encoding_rs" version = "0.8.34" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -140,6 +171,16 @@ dependencies = [ ] [[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -272,6 +313,54 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] +name = "rs_hasher_ctx" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a45ae5cc6246fa2666253289d6495e1fb3d125fb83842ff56b747a3b662e28e" +dependencies = [ + "rs_internal_hasher", + "rs_internal_state", + "rs_n_bit_words", +] + +[[package]] +name = "rs_internal_hasher" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19754b7c13d7fb92e995b1f6330918466e134ba7c3f55bf805c72e6a9727c426" +dependencies = [ + "rs_internal_state", + "rs_n_bit_words", +] + +[[package]] +name = "rs_internal_state" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "214a4e27fec5b651d615675874c6a829496cc2aa66e5f1b184ab05cb39fd3625" +dependencies = [ + "rs_n_bit_words", +] + +[[package]] +name = "rs_n_bit_words" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bc1bbb4c2a60f76b331e6ba70b5065e210fa6e72fc966c2d488736755d89cb6" + +[[package]] +name = "rs_sha512" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bb3ee2bcf2e0bd2ead2504c3b67d1fb34ae978a2014febc011f82fcbe58d56" +dependencies = [ + "rs_hasher_ctx", + "rs_internal_hasher", + "rs_internal_state", + "rs_n_bit_words", +] + +[[package]] name = "rustix" version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -381,6 +470,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] name = "unicode-bidi" version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -434,6 +529,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/Cargo.toml b/Cargo.toml @@ -11,8 +11,11 @@ rust-version = "1.79" feed-rs = "^2.0.0" #activitypub_federation = "^0.4.0" #json-ld = "^0.14.1" +digest = "^0.10.7" clap = "2.34.0" +#sha2 = "^0.10.8" #quick-xml = "^0.28.2" +rs_sha512 = "^0.1.3" [dev-dependencies] tempfile = "3.3.0" diff --git a/src/lib.rs b/src/lib.rs @@ -1,13 +1,21 @@ use std::collections::HashMap; +use std::hash::Hasher; +use std::hash::Hash; use std::iter::Iterator; use feed_rs::model::Entry; pub struct Sequencer { - pub items: HashMap<u32, Entry>, + pub items: HashMap<u32, Vec<u8>>, item_keys: Vec<u32>, crsr: usize, } +pub struct SequencerEntry<'a> { + entry: Entry, + summer: &'a dyn Hasher, + digest: Vec<u8>, +} + impl Sequencer { pub fn new() -> Sequencer { Sequencer { @@ -16,10 +24,31 @@ impl Sequencer { item_keys: Vec::<u32>::new(), } } + + pub fn add<H: Hash>(&self, entry: SequencerEntry) { +// entry.hash(&self, entry); + } } +impl<'a> SequencerEntry<'a> { + pub fn new(entry: Entry, summer: &'a dyn Hasher) -> SequencerEntry<'a> { + SequencerEntry { + entry: entry, + summer: summer, + digest: Vec::new(), + } + } +} + +//impl<'a> Hash for SequencerEntry<'a> { +// fn hash(&self) -> u64 { +// Vec::<u64>::new() +// } +//} +// + impl Iterator for Sequencer { - type Item = Entry; + type Item = Vec<u8>; fn next(&mut self) -> Option<Self::Item> { let c: u32; @@ -28,3 +57,17 @@ impl Iterator for Sequencer { return Some(self.items[&c].clone()); } } + +#[cfg(test)] +mod tests { + use rs_sha512::Sha512Hasher; + use super::SequencerEntry; + use feed_rs::model::Entry; + + #[test] + fn test_entry() { + let h = Sha512Hasher::default(); + let src = Entry::default(); + let entry = SequencerEntry::new(src, &h); + } +}