Module types

Module types 

Source
Expand description

Type-safe wrappers for Tor-specific identifiers and values.

This module provides newtype wrappers that enforce validation at construction time, preventing invalid values from being created. These types improve API safety and clarity by making invalid states unrepresentable.

§Design Philosophy

Following the library-rs reference implementation, these types:

  • Validate input at construction time
  • Provide infallible access after construction
  • Implement standard traits (Display, Debug, FromStr)
  • Use efficient internal representations

§Available Types

§Example

use stem_rs::types::{Fingerprint, Nickname};
use std::str::FromStr;

let fp = Fingerprint::from_str(
    "9695DFC35FFEB861329B9F1AB04C46397020CE31"
).unwrap();
println!("Fingerprint: {}", fp);

let nick = Nickname::from_str("MyRelay").unwrap();
println!("Nickname: {}", nick);

let invalid = Nickname::from_str("invalid-name");
assert!(invalid.is_err());

Structs§

Ed25519Identity
A validated Ed25519 identity.
Ed25519PublicKey
A validated Ed25519 public key.
Fingerprint
A validated relay fingerprint.
Nickname
A validated relay nickname.

Enums§

Ed25519IdentityError
Errors that can occur when parsing Ed25519 identities.
Ed25519PublicKeyError
Errors that can occur when parsing Ed25519 public keys.
FingerprintError
Errors that can occur when parsing or validating fingerprints.
NicknameError
Errors that can occur when parsing or validating nicknames.