Crate commonware_utils

Crate commonware_utils 

Source
Expand description

Leverage common functionality across multiple primitives.

Re-exports§

pub use sequence::Array;
pub use sequence::Span;
pub use net::IpAddrExt;
pub use time::DurationExt;
pub use time::SystemTimeExt;
pub use rational::BigRationalExt;

Modules§

bitmap
Bitmap implementation
channels
Utilities for working with channels.
concurrency
Utilities for managing concurrency.
futures
Utilities for working with futures.
hex_literal
Hex literal macro implementation.
net
Utilities for working with IP addresses.
rational
Utilities for working with num_rational::BigRational.
sequence
set
Ordered collections that guarantee sorted, deduplicated keys.
time
Utility functions for std::time.

Macros§

NZDuration
A macro to create a NonZeroDuration from a duration, panicking if the duration is zero.
NZU8
A macro to create a NonZeroU8 from a value, panicking if the value is zero.
NZU16
A macro to create a NonZeroU16 from a value, panicking if the value is zero.
NZU32
A macro to create a NonZeroU32 from a value, panicking if the value is zero.
NZU64
A macro to create a NonZeroU64 from a value, panicking if the value is zero.
NZUsize
A macro to create a NonZeroUsize from a value, panicking if the value is zero.
fixed_bytes
Macro for converting sequence of string literals containing hex-encoded data into a FixedBytes type.
hex
Macro for converting sequence of string literals containing hex-encoded data into an array of bytes.

Structs§

NonZeroDuration
A wrapper around Duration that guarantees the duration is non-zero.
PrioritySet
A set that offers efficient iteration over its elements in priority-ascending order.

Enums§

StableBuf
A buffer whose memory is stable as long as its not reallocated.

Functions§

from_hex
Converts a hexadecimal string to bytes.
from_hex_formatted
Converts a hexadecimal string to bytes, stripping whitespace and/or a 0x prefix. Commonly used in testing to encode external test vectors without modification.
hex
Converts bytes to a hexadecimal string.
max_faults
Compute the maximum number of f (faults) that can be tolerated for a given set of n participants. This is the maximum integer f such that n >= 3*f + 1. f may be zero.
modulo
Compute the modulo of bytes interpreted as a big-endian integer.
quorum
Compute the quorum size for a given set of n participants. This is the minimum integer q such that 3*q >= 2*n + 1. It is also equal to n - f, where f is the maximum number of faults.
quorum_from_slice
Compute the quorum size for a given slice.
union
Computes the union of two byte slices.
union_unique
Concatenate a namespace and a message, prepended by a varint encoding of the namespace length.