Crate okid

Source
Expand description

§👌🫆 okid

FOSSA Status

okid is a library for generating double clickable representations of various types of data, such as sha1 hashes, uuids and more.

§sha1

#[cfg(feature = "sha1")]
{
    use sha1::Digest as sha1digest;
    let hasher = sha1::Sha1::new();
    let binary_id = okid::OkId::from(hasher);
}

§sha256

#[cfg(feature = "sha2")]
{
    use sha2::Digest;
    let mut hasher = sha2::Sha256::new();
    hasher.update(b"hello world");
    let binary_id = okid::OkId::from(hasher);
}

The resulting strings look like this: 2ː00b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 first character of the string is the type of the binary data in this case 2 means sha256 the rest of the string is the hexadecimal representation of the binary data

§okid macro

The okid! macro can be used to parse OkIds from string literals at compile time.

use okid::{okid, OkId};
#[cfg(feature = "sha2")]
const HELLO_WORLD_SHA256: OkId = okid!("2ːb94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9");

§Development

§Build Tasks

This project uses cargo xtask for build automation. Available tasks:

# Build the Rust library
cargo xtask build

# Build the main WASM module
cargo xtask wasm

# Build and serve mdbook documentation
cargo xtask mdbook

# Build docs with all WASM modules
cargo xtask build-docs

# Run all tests
cargo xtask test

§License

FOSSA Status

Modules§

blake3blake3
blake3 module
fingerprint
fingerprint module
sha2sha2
sha2 module
sha3sha3
sha3 module
ulidulid
ulid module
uuiduuid
uuid module

Macros§

okidNon-macro-diagnostics
Parse OkIds from string literals at compile time.

Structs§

OkId
OkId is a double clickable representation of arbitrary binary data

Enums§

Error
Errors that can occur when parsing an OkId

Constants§

SEPARATOR
Separator character for the OkId string representation
SEPARATOR_BYTES
Separator bytes for the OkId string representation
SEPARATOR_BYTES_LEN
Separator bytes length for the OkId string representation

Traits§

FromDigest
FromDigest trait, a common trait that OkId can be converted from
IntoOkId
IntoOkId trait, a common trait that OkId can be converted from

Functions§

pathsafe
Create a path-safe string from an OkId