Trait Universe

Source
pub(crate) trait Universe {
    // Required methods
    fn contains<T: ChanTarget>(&self, guard: &T) -> Option<bool>;
    fn status<T: ChanTarget>(&self, guard: &T) -> CandidateStatus<Candidate>;
    fn timestamp(&self) -> SystemTime;
    fn weight_threshold<T>(
        &self,
        sample: &ByRelayIds<T>,
        params: &GuardParams,
    ) -> WeightThreshold
       where T: HasRelayIds;
    fn sample<T>(
        &self,
        pre_existing: &ByRelayIds<T>,
        filter: &GuardFilter,
        n: usize,
    ) -> Vec<(Candidate, RelayWeight)>
       where T: HasRelayIds;
}
Expand description

A “Universe” is a source from which guard candidates are drawn, and from which guards are updated.

Required Methods§

Source

fn contains<T: ChanTarget>(&self, guard: &T) -> Option<bool>

Check whether this universe contains a candidate for the given guard.

Return Some(true) if it definitely does; Some(false) if it definitely does not, and None if we cannot tell without downloading more information.

Source

fn status<T: ChanTarget>(&self, guard: &T) -> CandidateStatus<Candidate>

Return full information about a member of this universe for a given guard.

Source

fn timestamp(&self) -> SystemTime

Return an (approximate) timestamp describing when this universe was generated.

This timestamp is used to determine how long a guard has been listed or unlisted.

Source

fn weight_threshold<T>( &self, sample: &ByRelayIds<T>, params: &GuardParams, ) -> WeightThreshold
where T: HasRelayIds,

Return information about how much of this universe has been added to sample, and how much we’re willing to add according to params.

Source

fn sample<T>( &self, pre_existing: &ByRelayIds<T>, filter: &GuardFilter, n: usize, ) -> Vec<(Candidate, RelayWeight)>
where T: HasRelayIds,

Return up to n of new candidate guards from this Universe.

Only return elements that have no conflicts with identities in pre_existing, and which obey filter.

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.

Implementations on Foreign Types§

Source§

impl Universe for NetDir

Source§

fn timestamp(&self) -> SystemTime

Source§

fn contains<T: ChanTarget>(&self, guard: &T) -> Option<bool>

Source§

fn status<T: ChanTarget>(&self, guard: &T) -> CandidateStatus<Candidate>

Source§

fn weight_threshold<T>( &self, sample: &ByRelayIds<T>, params: &GuardParams, ) -> WeightThreshold
where T: HasRelayIds,

Source§

fn sample<T>( &self, pre_existing: &ByRelayIds<T>, filter: &GuardFilter, n: usize, ) -> Vec<(Candidate, RelayWeight)>
where T: HasRelayIds,

Implementors§

Source§

impl Universe for UniverseRef

Source§

impl Universe for BridgeSet

Available on crate feature bridge-client only.