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};
16use crate::parse::parser::Section;
17use crate::types::misc::*;
18use crate::types::relay_flags::{self, DocRelayFlags, RelayFlag, RelayFlags};
19use crate::types::version::TorVersion;
20use crate::{Error, NetdocErrorKind as EK, Result};
21use derive_deftly::Deftly;
22use itertools::chain;
23use std::sync::Arc;
24use std::{net, time};
25use tor_basic_utils::intern::InternCache;
26use tor_error::internal;
27use tor_llcrypto::pk::rsa::RsaIdentity;
28
29#[derive(Clone, Debug, Eq, PartialEq, Hash, derive_more::Display)]
35#[non_exhaustive]
36pub enum SoftwareVersion {
37 CTor(TorVersion),
39 Other(Arc<str>),
41}
42
43static OTHER_VERSION_CACHE: InternCache<str> = InternCache::new();
48
49#[derive(Debug, Clone, Default, Eq, PartialEq, Deftly)]
65#[derive_deftly(ItemValueParseable)]
66#[non_exhaustive]
67pub struct RouterStatusMdDigestsVote {
68 #[deftly(netdoc(with = consensus_methods_comma_separated))]
70 pub consensus_methods: ConsensusMethods,
71
72 pub digests: Vec<IdentifiedDigest>,
74}
75
76impl std::str::FromStr for SoftwareVersion {
77 type Err = Error;
78
79 fn from_str(s: &str) -> Result<Self> {
80 let mut elts = s.splitn(3, ' ');
81 if elts.next() == Some("Tor") {
82 if let Some(Ok(v)) = elts.next().map(str::parse) {
83 return Ok(SoftwareVersion::CTor(v));
84 }
85 }
86
87 Ok(SoftwareVersion::Other(OTHER_VERSION_CACHE.intern_ref(s)))
88 }
89}
90
91trait FromRsString: Sized {
94 fn decode(s: &str) -> Result<Self>;
96}