Crate tari_utilities

source ·
Expand description

A set of useful and commonly used utilities that are used in several places in the Tari project.



  • Functions for conversion between integer and bit array.
  • A trait that offers representation of data types as a byte array or hex string.
  • Function which tries to convert a series of Ts to Us.
  • A trait that handles base58 encoding and decoding.
  • Data structure representing time as a u64.
  • Data structure describing a fixed set of size n.
  • A simple Hashable trait which is used to describe how an object should be hashed.
  • Functions for conversion between binary and hex string.
  • Sometimes you need to handle sensitive data, like a passphrase or key material. There are pitfalls here that you want to avoid: the data should be zeroized when it goes out of scope, shouldn’t be displayed or output to debug logs, shouldn’t be unintentionally copied or moved, and often should have strict type differentiation to avoid it being misused in an unintended context. This library provides a generic type and macro that can help.
  • Macros for RwLock.
  • A MessageFormat trait that handles conversion from and to binary, json, or base64.
  • A type for handling a passphrase safely.
  • An array-like type with safety features that make it suitable for cryptographic keys.
  • A module with serialization utilities.


  • This macro returns a Mutex or RwLock guard without returning a PoisonError. If the lock is poisoned (i.e. a panic before a MutexGuard / RwLockGuard is dropped), the last value before the panic occurred is used. The semantics of this macro are similar to a database transaction rollback on failure.
  • Acquire a read lock on a RwLock, silently recovering the lock if it is poisoned
  • Acquire a write lock on a RwLock, silently recovering the lock if it is poisoned
  • This is a macro that produces a hidden type from an underlying data type.
  • Recovers a poisoned lock by returning the value before the lock was poisoned