#[non_exhaustive]pub enum SignatureAlgorithm {
MinHashV1,
MinHashLegacyV1,
}Expand description
A set-signature algorithm at one version of its definition.
A signature estimates how much two sets overlap, value by value, where a bit hash
(Algorithm) is compared bit by bit. The two never compare with each other. As with
Algorithm, the version is part of the identity and a released definition never changes its
output.
minhash-v1 and minhash-legacy-v1 are datasketch’s two 32-bit MinHash constructions, its
current default and the one it used before 2.0.0. Their signatures have the same shape but
different values, so they never compare, merge or parse as each other: choose one per stored
column.
use legit_hashes::SignatureAlgorithm;
let algorithm: SignatureAlgorithm = "minhash-v1".parse()?;
assert_eq!(algorithm, SignatureAlgorithm::MinHashV1);
assert_eq!(algorithm.value_count(), 128);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MinHashV1
minhash-v1: Broder’s MinHash, 128 values of 32 bits, as the Python library datasketch
computes it by default since 2.0.0, its affine32 scheme. See
minhash_v1.
MinHashLegacyV1
minhash-legacy-v1: Broder’s MinHash, 128 values of 32 bits, as datasketch computed it by
default before 2.0.0, its legacy scheme. See
minhash_legacy_v1.
Implementations§
Source§impl SignatureAlgorithm
impl SignatureAlgorithm
Sourcepub const ALL: [Self; 2]
pub const ALL: [Self; 2]
Every signature algorithm this version of the crate knows, in the order they were added.
use legit_hashes::SignatureAlgorithm;
assert_eq!(
SignatureAlgorithm::ALL,
[SignatureAlgorithm::MinHashV1, SignatureAlgorithm::MinHashLegacyV1]
);Sourcepub const fn id(self) -> &'static str
pub const fn id(self) -> &'static str
The stable text id, such as minhash-v1, used in every stored and printed form.
use legit_hashes::SignatureAlgorithm;
assert_eq!(SignatureAlgorithm::MinHashV1.id(), "minhash-v1");Sourcepub const fn value_count(self) -> u32
pub const fn value_count(self) -> u32
The number of 32-bit values in the algorithm’s signatures: 128 for both MinHash definitions.
use legit_hashes::SignatureAlgorithm;
assert_eq!(SignatureAlgorithm::MinHashV1.value_count(), 128);Sourcepub fn from_id(id: &str) -> Result<Self>
pub fn from_id(id: &str) -> Result<Self>
Find the signature algorithm with the text id id, such as minhash-v1. The match is
exact.
use legit_hashes::{Algorithm, Error, SignatureAlgorithm};
assert_eq!(SignatureAlgorithm::from_id("minhash-v1")?, SignatureAlgorithm::MinHashV1);
assert_eq!(
SignatureAlgorithm::from_id("simhash-v1"),
Err(Error::NotASignature(Algorithm::SimHashV1))
);§Errors
Returns Error::NotASignature for the id of a bit-hash Algorithm, and
Error::UnknownAlgorithm when no algorithm has that id.
Trait Implementations§
Source§impl Clone for SignatureAlgorithm
impl Clone for SignatureAlgorithm
impl Copy for SignatureAlgorithm
Source§impl Debug for SignatureAlgorithm
impl Debug for SignatureAlgorithm
Source§impl<'de> Deserialize<'de> for SignatureAlgorithm
Available on crate feature serde only.
impl<'de> Deserialize<'de> for SignatureAlgorithm
serde only.Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize from the id.
Source§impl Display for SignatureAlgorithm
impl Display for SignatureAlgorithm
impl Eq for SignatureAlgorithm
Source§impl FromStr for SignatureAlgorithm
impl FromStr for SignatureAlgorithm
Source§impl Hash for SignatureAlgorithm
impl Hash for SignatureAlgorithm
Source§impl Ord for SignatureAlgorithm
impl Ord for SignatureAlgorithm
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SignatureAlgorithm
impl PartialEq for SignatureAlgorithm
Source§impl PartialOrd for SignatureAlgorithm
impl PartialOrd for SignatureAlgorithm
Source§impl Serialize for SignatureAlgorithm
Available on crate feature serde only.
impl Serialize for SignatureAlgorithm
serde only.