Struct ValidatorMap

Source
pub struct ValidatorMap<T>(/* private fields */);
Expand description

A map from the set of validators to some values.

Implementations§

Source§

impl<C: Context> ValidatorMap<Observation<C>>

Source

pub fn has_correct(&self) -> bool

Returns true if there is at least one correct observation.

Source

pub fn iter_correct<'a>( &'a self, state: &'a State<C>, ) -> impl Iterator<Item = &'a Unit<C>>

Returns an iterator over all honest validators’ latest units.

Source

pub fn iter_correct_hashes(&self) -> impl Iterator<Item = &C::Hash>

Returns an iterator over all honest validators’ latest units’ hashes.

Source

pub fn iter_faulty(&self) -> impl Iterator<Item = ValidatorIndex> + '_

Returns an iterator over all faulty validators’ indices.

Source

pub fn iter_none(&self) -> impl Iterator<Item = ValidatorIndex> + '_

Returns an iterator over all faulty validators’ indices.

Source

pub fn sees_correct(&self, state: &State<C>, hash: &C::Hash) -> bool

Returns true if self sees the creator of hash as correct, and sees that unit.

Source

pub fn sees(&self, state: &State<C>, hash_to_be_found: &C::Hash) -> bool

Returns true if self sees the unit with the specified hash.

Source

pub fn cutoff(&self, state: &State<C>, timestamp: Timestamp) -> Panorama<C>

Returns the panorama seeing all units seen by self with a timestamp no later than timestamp. Accusations are preserved regardless of the evidence’s timestamp.

Source

pub fn geq(&self, state: &State<C>, other: &Panorama<C>) -> bool

Returns whether self can possibly come later in time than other, i.e. it can see every honest message and every fault seen by other.

Source§

impl<T> ValidatorMap<T>

Source

pub fn get(&self, idx: ValidatorIndex) -> Option<&T>

Returns the value for the given validator, or None if the index is out of range.

Source

pub fn len(&self) -> usize

Returns the number of values. This must equal the number of validators.

Source

pub fn is_empty(&self) -> bool

Returns true if this ValidatorMap is empty.

Source

pub fn iter(&self) -> impl Iterator<Item = &T>

Returns an iterator over all values.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>

Returns an iterator over mutable references to all values.

Source

pub fn enumerate(&self) -> impl Iterator<Item = (ValidatorIndex, &T)>

Returns an iterator over all values, by validator index.

Source

pub fn has(&self, idx: ValidatorIndex) -> bool

Returns true if self has an entry for validator number idx.

Source

pub fn keys(&self) -> impl Iterator<Item = ValidatorIndex>

Returns an iterator over all validator indices.

Binary searches this sorted ValidatorMap for x.

Returns the lowest index of an entry >= x, or None if x is greater than all entries.

Source§

impl<T> ValidatorMap<Option<T>>

Source

pub fn keys_some(&self) -> impl Iterator<Item = ValidatorIndex> + '_

Returns the keys of all validators whose value is Some.

Source

pub fn iter_some(&self) -> impl Iterator<Item = (ValidatorIndex, &T)> + '_

Returns an iterator over all values that are present, together with their index.

Trait Implementations§

Source§

impl<Rhs, T: Copy + Add<Rhs, Output = T>> Add<ValidatorMap<Rhs>> for ValidatorMap<T>

Source§

type Output = ValidatorMap<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ValidatorMap<Rhs>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> AsRef<Vec<T>> for ValidatorMap<T>

Source§

fn as_ref(&self) -> &Vec<T>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T: Clone> Clone for ValidatorMap<T>

Source§

fn clone(&self) -> ValidatorMap<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> DataSize for ValidatorMap<T>
where T: DataSize,

Source§

const IS_DYNAMIC: bool = true

If true, the type has a heap size that can vary at runtime, depending on the actual value.
Source§

const STATIC_HEAP_SIZE: usize = 0usize

The amount of space a value of the type always occupies. If IS_DYNAMIC is false, this is the total amount of heap memory occupied by the value. Otherwise this is a lower bound.
Source§

fn estimate_heap_size(&self) -> usize

Estimates the size of heap memory taken up by this value. Read more
Source§

fn estimate_detailed_heap_size(&self) -> MemUsageNode

Create a tree of memory estimations. Read more
Source§

impl<T: Debug> Debug for ValidatorMap<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, T> Deserialize<'de> for ValidatorMap<T>
where T: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T> Display for ValidatorMap<Option<T>>
where T: Display,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> From<Vec<T>> for ValidatorMap<T>

Source§

fn from(original: Vec<T>) -> ValidatorMap<T>

Converts to this type from the input type.
Source§

impl<T> FromIterator<T> for ValidatorMap<T>

Source§

fn from_iter<I: IntoIterator<Item = T>>(ii: I) -> ValidatorMap<T>

Creates a value from an iterator. Read more
Source§

impl<T: Hash> Hash for ValidatorMap<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> Index<ValidatorIndex> for ValidatorMap<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, vidx: ValidatorIndex) -> &T

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<ValidatorIndex> for ValidatorMap<T>

Source§

fn index_mut(&mut self, vidx: ValidatorIndex) -> &mut T

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a ValidatorMap<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T> IntoIterator for ValidatorMap<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq> PartialEq for ValidatorMap<T>

Source§

fn eq(&self, other: &ValidatorMap<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for ValidatorMap<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Eq> Eq for ValidatorMap<T>

Source§

impl<T> StructuralPartialEq for ValidatorMap<T>

Auto Trait Implementations§

§

impl<T> Freeze for ValidatorMap<T>

§

impl<T> RefUnwindSafe for ValidatorMap<T>
where T: RefUnwindSafe,

§

impl<T> Send for ValidatorMap<T>
where T: Send,

§

impl<T> Sync for ValidatorMap<T>
where T: Sync,

§

impl<T> Unpin for ValidatorMap<T>
where T: Unpin,

§

impl<T> UnwindSafe for ValidatorMap<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<From, To> FallibleInto<To> for From
where To: TryFrom<From>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcastable for T
where T: Any + Send + Sync + 'static,

Source§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
Source§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
Source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,