#[cfg(feature = "build_docs")]
pub(crate) mod build;
pub(crate) mod md;
#[cfg(feature = "plain-consensus")]
pub(crate) mod plain;
#[cfg(feature = "ns-vote")]
pub(crate) mod vote;
use super::{ConsensusFlavor, ConsensusMethods};
use crate::doc::netstatus::NetstatusKwd;
use crate::doc::netstatus::{IgnoredPublicationTimeSp, Protocols, RelayWeight};
use crate::parse::parser::Section;
use crate::types::misc::*;
use crate::types::relay_flags::{self, DocRelayFlags, RelayFlag, RelayFlags};
use crate::types::version::TorVersion;
use crate::{Error, NetdocErrorKind as EK, Result};
use itertools::chain;
use std::sync::Arc;
use std::{net, time};
use tor_basic_utils::intern::InternCache;
use tor_error::internal;
use tor_llcrypto::pk::rsa::RsaIdentity;
#[cfg(feature = "parse2")]
use {
super::consensus_methods_comma_separated, derive_deftly::Deftly,
};
#[derive(Clone, Debug, Eq, PartialEq, Hash, derive_more::Display)]
#[non_exhaustive]
pub enum SoftwareVersion {
CTor(TorVersion),
Other(Arc<str>),
}
static OTHER_VERSION_CACHE: InternCache<str> = InternCache::new();
#[derive(Debug, Clone, Default, Eq, PartialEq)]
#[cfg(feature = "ns-vote")]
#[cfg_attr(feature = "parse2", derive(Deftly), derive_deftly(ItemValueParseable))]
#[non_exhaustive]
pub struct RouterStatusMdDigestsVote {
#[cfg_attr(
feature = "parse2",
deftly(netdoc(with = "consensus_methods_comma_separated"))
)]
pub consensus_methods: ConsensusMethods,
pub digests: Vec<IdentifiedDigest>,
}
impl std::str::FromStr for SoftwareVersion {
type Err = Error;
fn from_str(s: &str) -> Result<Self> {
let mut elts = s.splitn(3, ' ');
if elts.next() == Some("Tor") {
if let Some(Ok(v)) = elts.next().map(str::parse) {
return Ok(SoftwareVersion::CTor(v));
}
}
Ok(SoftwareVersion::Other(OTHER_VERSION_CACHE.intern_ref(s)))
}
}
trait FromRsString: Sized {
fn decode(s: &str) -> Result<Self>;
}