1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! One implementation of the [`legit_hashes`] definitions for callers in any language: requests in
//! and results out as JSON lines, from a command line or, with the `serve` feature, Redis Streams.
//!
//! The `legit-hasher` binary is a thin shell around this library. The core is [`hash`], one
//! [`Request`] in and one [`Outcome`] out, which never panics and turns every failure into an
//! error result. [`run`] drives a batch of requests on a pool of threads with bounded memory,
//! skipping those an earlier run's output already answers ([`Finished`]). [`distances`] compares
//! stored hashes and signatures, and [`Info`] reports the definitions, the limits and the CPU.
//!
//! ```
//! use legit_hasher::{Request, Settings, Status, hash};
//!
//! let line = br#"{"id": "greeting", "text": "hello there, world",
//! "options": {"format": 1, "definitions": [{"id": "minhash-v1", "shingle": 5, "band_keys": 16}]}}"#;
//! let request = Request::from_json(line).map_err(|outcome| outcome.to_json())?;
//! let outcome = hash(&request, Settings::default());
//! assert_eq!(outcome.status, Status::Success);
//! let result = &outcome.hashes.as_ref().expect("a successful result has hashes")[0];
//! assert!(result.value.as_deref().is_some_and(|value| value.starts_with("minhash-v1:")));
//! assert_eq!(result.band_keys.as_ref().map(Vec::len), Some(16));
//! # Ok::<(), String>(())
//! ```
//!
//! A definition's output is the same on every machine. The runner detects the CPU only to report
//! it; nothing it detects changes a hash.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use Finished;
pub use ;
/// The version of the request and result formats: `1`. Every result line and `info` carry it,
/// and a request's `options` must name it. A breaking change to either format raises it.
pub const FORMAT: u32 = 1;
/// The README's examples, compiled and run as doctests.
;