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§
Sourcefn contains<T: ChanTarget>(&self, guard: &T) -> Option<bool>
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.
Sourcefn status<T: ChanTarget>(&self, guard: &T) -> CandidateStatus<Candidate>
fn status<T: ChanTarget>(&self, guard: &T) -> CandidateStatus<Candidate>
Return full information about a member of this universe for a given guard.
Sourcefn timestamp(&self) -> SystemTime
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.
Sourcefn weight_threshold<T>(
&self,
sample: &ByRelayIds<T>,
params: &GuardParams,
) -> WeightThresholdwhere
T: HasRelayIds,
fn weight_threshold<T>(
&self,
sample: &ByRelayIds<T>,
params: &GuardParams,
) -> WeightThresholdwhere
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
.
Sourcefn sample<T>(
&self,
pre_existing: &ByRelayIds<T>,
filter: &GuardFilter,
n: usize,
) -> Vec<(Candidate, RelayWeight)>where
T: HasRelayIds,
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.