pub trait Faults {
// Required method
fn max_faults(n: impl ToPrimitive) -> u32;
// Provided methods
fn quorum(n: impl ToPrimitive) -> u32 { ... }
fn quorum_from_slice<T>(slice: &[T]) -> u32 { ... }
}Expand description
A Byzantine fault tolerance model that defines quorum calculations.
Different consensus protocols require different fault tolerance guarantees. This trait abstracts over those requirements, allowing protocols to be parameterized by their fault model.
All methods accept any integer type that implements ToPrimitive, allowing
callers to use u32, u64, i32, usize, etc. without explicit conversion.
Output is always u32.
Required Methods§
Sourcefn max_faults(n: impl ToPrimitive) -> u32
fn max_faults(n: impl ToPrimitive) -> u32
Compute the maximum number of faults that can be tolerated for n participants.
This is the maximum integer f such that the protocol’s safety and liveness
properties hold when up to f participants are Byzantine.
§Panics
Panics if n is zero, negative, or exceeds u32::MAX.
Provided Methods§
Sourcefn quorum(n: impl ToPrimitive) -> u32
fn quorum(n: impl ToPrimitive) -> u32
Compute the quorum size for n participants.
This is the minimum number of participants that must agree for the protocol
to make progress. It equals n - max_faults(n).
§Panics
Panics if n is zero, negative, or exceeds u32::MAX.
Sourcefn quorum_from_slice<T>(slice: &[T]) -> u32
fn quorum_from_slice<T>(slice: &[T]) -> u32
Compute the quorum size from a slice length.
Convenience method that converts the slice length to u32 and calls Self::quorum.
§Panics
Panics if the slice is empty or its length exceeds u32::MAX.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.