pub struct ParamValues<T> { /* private fields */ }Expand description
A set of named parameter values
These are used to describe current settings for the Tor network, current weighting parameters for path selection, and so on. They’re encoded with a space-separated K=V format.
§Overview of types for representing (network) parameter
This is at the root of four related types:
-
tor_netdir::NetParameters: refined consensus parameters, ready for use.- impossible to accidentally refer to undefined parameter names
- spec’s defaults are applied
- values’ ranges are checked
-
NetParams: network parameter settings fromparamsin a consensus (or vote), parsed, but without interpretation and without defaults applied. This is the type of theparamsfield in aNetworkStatus.- caller must get field names right; no central keyword list
- user is reminded to apply defaults, but must do so manually
- values are all unchecked
i32
-
NetParamValues: a set of network parameter values, for example as found in configuration for overriding netparams.NetParamscontains one of these.- no checking of field names or values
- missing values simply return
Nonefromget, nothing to stop failure to apply a default when needed (which is appropriate for an override set).
-
ParamValues<T>: any kind of key=values list as used in various network documents, generic over the value typeT.- no checking of field names or values, no defaulting
- arbitrary value type - some netdoc elements have
u32, somei32, etc.
§In netdocs
Syntax is that found in params in a network status:
https://spec.torproject.org/dir-spec/consensus-formats.html#item:params,
The same syntax is also used, and this type used for parsing, in various other places,
for example routerstatus entry w items (bandwidths):
https://spec.torproject.org/dir-spec/consensus-formats.html#item:w
Implementations§
Source§impl<T> ParamValues<T>
impl<T> ParamValues<T>
Sourcepub fn get<A: AsRef<str>>(&self, v: A) -> Option<&T>
pub fn get<A: AsRef<str>>(&self, v: A) -> Option<&T>
Retrieve a given network parameter, if it is present.
There is no safeguard against getting parameter names wrong.
Sourcepub fn iter(&self) -> impl Iterator<Item = (&String, &T)>
pub fn iter(&self) -> impl Iterator<Item = (&String, &T)>
Return an iterator over all key value pairs in an arbitrary order.
Trait Implementations§
Source§impl<T: Clone> Clone for ParamValues<T>
impl<T: Clone> Clone for ParamValues<T>
Source§impl<T: Debug> Debug for ParamValues<T>
impl<T: Debug> Debug for ParamValues<T>
Source§impl<T> Default for ParamValues<T>
impl<T> Default for ParamValues<T>
Source§impl<'de, T> Deserialize<'de> for ParamValues<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for ParamValues<T>where
T: Deserialize<'de>,
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
impl<T: Eq> Eq for ParamValues<T>
Source§impl<T> Extend<(String, T)> for ParamValues<T>
impl<T> Extend<(String, T)> for ParamValues<T>
Source§fn extend<I: IntoIterator<Item = (String, T)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (String, T)>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<ParamValues<i32>> for NetParams
impl From<ParamValues<i32>> for NetParams
Source§fn from(value: NetParamValues) -> Self
fn from(value: NetParamValues) -> Self
Source§impl<K: Into<String>, T> FromIterator<(K, T)> for ParamValues<T>
impl<K: Into<String>, T> FromIterator<(K, T)> for ParamValues<T>
Source§impl<T> FromStr for ParamValues<T>
impl<T> FromStr for ParamValues<T>
Source§impl<T: NormalItemArgument + Ord + Display> ItemValueEncodable for ParamValues<T>
impl<T: NormalItemArgument + Ord + Display> ItemValueEncodable for ParamValues<T>
Source§fn write_item_value_onto(&self, out: ItemEncoder<'_>) -> Result<(), Bug>
fn write_item_value_onto(&self, out: ItemEncoder<'_>) -> Result<(), Bug>
out Read moreSource§impl<T: FromStr + NormalItemArgument> ItemValueParseable for ParamValues<T>
impl<T: FromStr + NormalItemArgument> ItemValueParseable for ParamValues<T>
Source§fn from_unparsed(item: UnparsedItem<'_>) -> Result<Self, EP>
fn from_unparsed(item: UnparsedItem<'_>) -> Result<Self, EP>
Source§impl<T: PartialEq> PartialEq for ParamValues<T>
impl<T: PartialEq> PartialEq for ParamValues<T>
impl<T: PartialEq> StructuralPartialEq for ParamValues<T>
Source§impl TryFrom<&ParamValues<u32>> for RelayBandwidth
impl TryFrom<&ParamValues<u32>> for RelayBandwidth
Source§type Error = InvalidRelayBandwidth
type Error = InvalidRelayBandwidth
Source§fn try_from(
params: &ParamValues<u32>,
) -> Result<RelayBandwidth, InvalidRelayBandwidth>
fn try_from( params: &ParamValues<u32>, ) -> Result<RelayBandwidth, InvalidRelayBandwidth>
Source§impl TryFrom<ParamValues<u32>> for RelayBandwidthItem
Available on crate feature retain-unknown only.
impl TryFrom<ParamValues<u32>> for RelayBandwidthItem
retain-unknown only.Source§type Error = InvalidRelayBandwidth
type Error = InvalidRelayBandwidth
Source§fn try_from(
params: ParamValues<u32>,
) -> Result<RelayBandwidthItem, InvalidRelayBandwidth>
fn try_from( params: ParamValues<u32>, ) -> Result<RelayBandwidthItem, InvalidRelayBandwidth>
Auto Trait Implementations§
impl<T> Forget for ParamValues<T>
impl<T> Freeze for ParamValues<T>
impl<T> Move for ParamValues<T>
impl<T> RefUnwindSafe for ParamValues<T>where
T: RefUnwindSafe,
impl<T> Send for ParamValues<T>
impl<T> Sync for ParamValues<T>
impl<T> Unpin for ParamValues<T>
impl<T> UnsafeUnpin for ParamValues<T>
impl<T> UnwindSafe for ParamValues<T>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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