Struct tor_netdoc::doc::netstatus::Consensus

source ·
#[non_exhaustive]
pub struct Consensus<RS> { pub header: ConsensusHeader, pub voters: Vec<ConsensusVoterInfo>, pub relays: Vec<RS>, pub footer: Footer, }
Expand description

A single microdescriptor consensus netstatus

TODO: This should possibly turn into a parameterized type, to represent votes and ns consensuses.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§header: ConsensusHeader
Available on crate feature dangerous-expose-struct-fields only.

Part of the header shared by all consensus types.

§voters: Vec<ConsensusVoterInfo>
Available on crate feature dangerous-expose-struct-fields only.

List of voters whose votes contributed to this consensus.

§relays: Vec<RS>
Available on crate feature dangerous-expose-struct-fields only.

A list of routerstatus entries for the relays on the network, with one entry per relay.

These are currently ordered by the router’s RSA identity, but this is not to be relied on, since we may want to even abolish RSA at some point!

§footer: Footer
Available on crate feature dangerous-expose-struct-fields only.

Footer for the consensus object.

Implementations§

source§

impl<RS> Consensus<RS>

source

pub fn lifetime(&self) -> &Lifetime

Return the Lifetime for this consensus.

source

pub fn relays(&self) -> &[RS]

Return a slice of all the routerstatus entries in this consensus.

source

pub fn bandwidth_weights(&self) -> &NetParams<i32>

Return a mapping from keywords to integers representing how to weight different kinds of relays in different path positions.

source

pub fn params(&self) -> &NetParams<i32>

Return the map of network parameters that this consensus advertises.

source

pub fn shared_rand_cur(&self) -> Option<&SharedRandStatus>

Return the latest shared random value, if the consensus contains one.

source

pub fn shared_rand_prev(&self) -> Option<&SharedRandStatus>

Return the previous shared random value, if the consensus contains one.

source

pub fn relay_protocol_status(&self) -> &ProtoStatus

Return a ProtoStatus that lists the network’s current requirements and recommendations for the list of protocols that every relay must implement.

source

pub fn client_protocol_status(&self) -> &ProtoStatus

Return a ProtoStatus that lists the network’s current requirements and recommendations for the list of protocols that every client must implement.

source§

impl<RS: RouterStatus + ParseRouterStatus> Consensus<RS>

source

pub fn builder() -> ConsensusBuilder<RS>

Available on crate feature build_docs only.

Return a new ConsensusBuilder for building test consensus objects.

This function is only available when the build_docs feature has been enabled.

source

pub fn parse(s: &str) -> Result<(&str, &str, UncheckedConsensus<RS>)>

Try to parse a single networkstatus document from a string.

Trait Implementations§

source§

impl<RS: Clone> Clone for Consensus<RS>

source§

fn clone(&self) -> Consensus<RS>

Returns a copy 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<RS: Debug> Debug for Consensus<RS>

source§

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

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

impl<RS> ExternallySigned<Consensus<RS>> for UnvalidatedConsensus<RS>

§

type Key = [AuthCert]

The type of the public key object. Read more
§

type KeyHint = Vec<AuthCertKeyIds>

A type that describes what keys are missing for this object.
§

type Error = Error

An error type that’s returned when the object is not well-signed.
source§

fn key_is_correct(&self, k: &Self::Key) -> Result<(), Self::KeyHint>

Check whether k is the right key for this object. If not, return an error describing what key would be right. Read more
source§

fn is_well_signed(&self, k: &Self::Key) -> Result<(), Self::Error>

Check the signature on this object
source§

fn dangerously_assume_wellsigned(self) -> Consensus<RS>

Unwrap this object without checking any signatures on it.
source§

fn check_signature(self, k: &Self::Key) -> Result<T, Self::Error>

Unwrap this object if it’s correctly signed by a provided key.

Auto Trait Implementations§

§

impl<RS> Freeze for Consensus<RS>

§

impl<RS> RefUnwindSafe for Consensus<RS>
where RS: RefUnwindSafe,

§

impl<RS> Send for Consensus<RS>
where RS: Send,

§

impl<RS> Sync for Consensus<RS>
where RS: Sync,

§

impl<RS> Unpin for Consensus<RS>
where RS: Unpin,

§

impl<RS> UnwindSafe for Consensus<RS>
where RS: 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> 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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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