DescriptorType

Enum DescriptorType 

Source
pub enum DescriptorType {
Show 13 variants ServerDescriptor, ExtraInfo, Microdescriptor, NetworkStatusConsensusV3, NetworkStatusVoteV3, NetworkStatusMicrodescConsensusV3, BridgeNetworkStatus, BridgeServerDescriptor, BridgeExtraInfo, DirKeyCertificateV3, TorDNSEL, HiddenServiceDescriptor, BandwidthFile,
}
Expand description

Known descriptor types in the Tor network.

This enum represents all descriptor types that can be identified from type annotations or filenames. Each variant corresponds to a specific descriptor format defined in the Tor directory protocol specification.

§Stability

This enum is non-exhaustive. New descriptor types may be added in future Tor versions.

§Example

use stem_rs::descriptor::{DescriptorType, TypeAnnotation};

// From type annotation
let annotation = TypeAnnotation::new("server-descriptor", 1, 0);
let desc_type = DescriptorType::from_annotation(&annotation);
assert_eq!(desc_type, Some(DescriptorType::ServerDescriptor));

// From filename
let desc_type = DescriptorType::from_filename("cached-consensus");
assert_eq!(desc_type, Some(DescriptorType::NetworkStatusConsensusV3));

Variants§

§

ServerDescriptor

Server descriptor containing full relay metadata.

Includes identity keys, exit policy, bandwidth, and other relay information. Annotation name: server-descriptor

§

ExtraInfo

Extra-info descriptor with bandwidth statistics.

Contains detailed statistics about relay operation. Annotation name: extra-info

§

Microdescriptor

Microdescriptor with compact routing information.

Used by clients for building circuits with minimal data. Annotation name: microdescriptor

§

NetworkStatusConsensusV3

Network status consensus document (v3).

The agreed-upon view of the network signed by directory authorities. Annotation name: network-status-consensus-3

§

NetworkStatusVoteV3

Network status vote document (v3).

Individual directory authority’s view before consensus. Annotation name: network-status-vote-3

§

NetworkStatusMicrodescConsensusV3

Microdescriptor-flavored consensus document (v3).

Consensus using microdescriptor hashes instead of full descriptors. Annotation name: network-status-microdesc-consensus-3

§

BridgeNetworkStatus

Bridge network status document.

Network status for bridge relays (not publicly listed). Annotation name: bridge-network-status

§

BridgeServerDescriptor

Bridge server descriptor.

Server descriptor for bridge relays with some fields redacted. Annotation name: bridge-server-descriptor

§

BridgeExtraInfo

Bridge extra-info descriptor.

Extra-info for bridge relays. Annotation name: bridge-extra-info

§

DirKeyCertificateV3

Directory key certificate (v3).

Certificate binding a directory authority’s signing key to its identity. Annotation name: dir-key-certificate-3

§

TorDNSEL

TorDNSEL exit list.

List of exit relay IP addresses from the TorDNSEL service. Annotation name: tordnsel

§

HiddenServiceDescriptor

Hidden service descriptor.

Descriptor for onion services (v2 or v3). Annotation name: hidden-service-descriptor

§

BandwidthFile

Bandwidth authority measurement file.

Bandwidth measurements from bandwidth authorities. Annotation name: bandwidth-file

Implementations§

Source§

impl DescriptorType

Source

pub fn annotation_name(&self) -> &'static str

Returns the annotation name for this descriptor type.

This is the name used in @type annotations in CollecTor archives.

§Example
use stem_rs::descriptor::DescriptorType;

assert_eq!(DescriptorType::ServerDescriptor.annotation_name(), "server-descriptor");
assert_eq!(DescriptorType::Microdescriptor.annotation_name(), "microdescriptor");
Source

pub fn from_annotation(annotation: &TypeAnnotation) -> Option<Self>

Determines the descriptor type from a type annotation.

Returns None if the annotation name is not recognized.

§Arguments
  • annotation - The type annotation to match
§Example
use stem_rs::descriptor::{DescriptorType, TypeAnnotation};

let annotation = TypeAnnotation::new("extra-info", 1, 0);
assert_eq!(
    DescriptorType::from_annotation(&annotation),
    Some(DescriptorType::ExtraInfo)
);

let unknown = TypeAnnotation::new("unknown-type", 1, 0);
assert_eq!(DescriptorType::from_annotation(&unknown), None);
Source

pub fn from_filename(filename: &str) -> Option<Self>

Determines the descriptor type from a filename.

This is useful for parsing descriptors from Tor’s data directory where files have conventional names like cached-descriptors or cached-consensus.

Returns None if the filename doesn’t match a known pattern.

§Arguments
  • filename - The filename to match (path components are stripped)
§Example
use stem_rs::descriptor::DescriptorType;

assert_eq!(
    DescriptorType::from_filename("cached-descriptors"),
    Some(DescriptorType::ServerDescriptor)
);
assert_eq!(
    DescriptorType::from_filename("cached-extrainfo"),
    Some(DescriptorType::ExtraInfo)
);
assert_eq!(
    DescriptorType::from_filename("/var/lib/tor/cached-consensus"),
    Some(DescriptorType::NetworkStatusConsensusV3)
);
assert_eq!(DescriptorType::from_filename("unknown-file"), None);

Trait Implementations§

Source§

impl Clone for DescriptorType

Source§

fn clone(&self) -> DescriptorType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DescriptorType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for DescriptorType

Source§

fn eq(&self, other: &DescriptorType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for DescriptorType

Source§

impl Eq for DescriptorType

Source§

impl StructuralPartialEq for DescriptorType

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.