ValidatorAddress

Trait ValidatorAddress 

Source
pub trait ValidatorAddress:
    Sync
    + Send
    + Ord
    + Display
    + Debug
    + Default
    + Clone
    + Into<Vec<u8>>
    + Serialize
    + DeserializeOwned { }
Expand description

A trait for consensus validator addresses.

This trait defines the requirements for validator address types used in the consensus engine. Your validator address type must implement all the required traits to be compatible with the consensus engine.

§Required Traits

  • Sync + Send: Thread-safe and sendable across threads
  • Ord + Display + Debug + Default + Clone: Standard Rust traits for ordering, display, debugging, default values, and cloning
  • Into<Vec<u8>>: Convertible to bytes for serialization
  • Serialize + DeserializeOwned: Serde serialization support

§Example Implementation

#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
struct MyAddress(String);

impl std::fmt::Display for MyAddress {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", self.0)
    }
}

impl From<MyAddress> for Vec<u8> {
    fn from(addr: MyAddress) -> Self {
        addr.0.into_bytes()
    }
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§