tor_netdoc/doc/netstatus/
rs.rs1#[cfg(feature = "build_docs")]
7pub(crate) mod build;
8pub(crate) mod md;
9pub(crate) mod plain;
10#[cfg(feature = "incomplete")]
11pub(crate) mod vote;
12
13use super::{ConsensusFlavor, ConsensusMethods, consensus_methods_comma_separated};
14use crate::doc::netstatus::NetstatusKwd;
15use crate::doc::netstatus::{IgnoredPublicationTimeSp, Protocols, RelayWeight, RelayWeightsItem};
16use crate::encode::ItemEncoder;
17use crate::parse::parser::Section;
18use crate::parse2::ItemArgumentParseable;
19use crate::types::misc::*;
20use crate::types::relay_flags::{self, DocRelayFlags, RelayFlag, RelayFlags};
21use crate::types::version::TorVersion;
22use crate::{Error, NetdocErrorKind as EK, Result};
23use derive_deftly::Deftly;
24use itertools::chain;
25use std::sync::Arc;
26use std::{net, time};
27use tor_basic_utils::intern::InternCache;
28use tor_error::{Bug, internal};
29use tor_llcrypto::pk::rsa::RsaIdentity;
30
31#[derive(Clone, Debug, Eq, PartialEq, Hash, derive_more::Display)]
37#[non_exhaustive]
38pub enum SoftwareVersion {
39 CTor(TorVersion),
41 Other(Arc<str>),
43}
44
45static OTHER_VERSION_CACHE: InternCache<str> = InternCache::new();
50
51#[derive(Debug, Clone, Default, Eq, PartialEq, Ord, PartialOrd, Deftly)]
67#[derive_deftly(ItemValueParseable)]
68#[cfg_attr(feature = "incomplete", derive_deftly(ItemValueEncodable))] #[non_exhaustive]
70pub struct RouterStatusMdDigestsVote {
71 #[deftly(netdoc(with = consensus_methods_comma_separated))]
73 pub consensus_methods: ConsensusMethods,
74
75 pub digests: Vec<IdentifiedDigest>,
77}
78
79impl std::str::FromStr for SoftwareVersion {
80 type Err = Error;
81
82 fn from_str(s: &str) -> Result<Self> {
83 let mut elts = s.splitn(3, ' ');
84 if elts.next() == Some("Tor") {
85 if let Some(Ok(v)) = elts.next().map(str::parse) {
86 return Ok(SoftwareVersion::CTor(v));
87 }
88 }
89
90 Ok(SoftwareVersion::Other(OTHER_VERSION_CACHE.intern_ref(s)))
91 }
92}
93
94trait FromRsString: Sized {
97 fn decode(s: &str) -> Result<Self>;
99}