pub fn validate(self) -> Result<Config, ConfigError> {
        // Roll a random election time out based on the configured min & max or their respective defaults.
        let election_timeout_min = self
            .election_timeout_min
            .unwrap_or(DEFAULT_ELECTION_TIMEOUT_MIN);
        let election_timeout_max = self
            .election_timeout_max
            .unwrap_or(DEFAULT_ELECTION_TIMEOUT_MAX);
        if election_timeout_min >= election_timeout_max {
            return Err(ConfigError::InvalidElectionTimeoutMinMax);
        }
        // Get other values or their defaults.
        let heartbeat_interval = self
            .heartbeat_interval
            .unwrap_or(DEFAULT_HEARTBEAT_INTERVAL);
        let max_payload_entries = self
            .max_payload_entries
            .unwrap_or(DEFAULT_MAX_PAYLOAD_ENTRIES);
        if max_payload_entries == 0 {
            return Err(ConfigError::MaxPayloadEntriesTooSmall);
        }
        let replication_lag_threshold = self
            .replication_lag_threshold
            .unwrap_or(DEFAULT_REPLICATION_LAG_THRESHOLD);
        let snapshot_policy = self.snapshot_policy.unwrap_or_else(SnapshotPolicy::default);
        let snapshot_max_chunk_size = self
            .snapshot_max_chunk_size
            .unwrap_or(DEFAULT_SNAPSHOT_CHUNKSIZE);
        let catch_up_cancellation_policy = self
            .catch_up_cancellation_policy
            .unwrap_or_else(CatchUpCancellationPolicy::default);
        Ok(Config {
            cluster_name: self.cluster_name,
            election_timeout_min,
            election_timeout_max,
            heartbeat_interval,
            max_payload_entries,
            replication_lag_threshold,
            snapshot_policy,
            snapshot_max_chunk_size,
            catch_up_cancellation_policy,
        })
    }
/// Validate the state of this builder and produce a new `Config` instance if valid.
Validate the state of this builder and produce a new `Config` instance if valid.
Validate the state of this builder and produce a new ` Config ` instance if valid .
pub fn validate(self) -> Result<Config, ConfigError> {
        // Roll a random election time out based on the configured min & max or their respective defaults.
        let election_timeout_min = self
            .election_timeout_min
            .unwrap_or(DEFAULT_ELECTION_TIMEOUT_MIN);
        let election_timeout_max = self
            .election_timeout_max
            .unwrap_or(DEFAULT_ELECTION_TIMEOUT_MAX);
        if election_timeout_min >= election_timeout_max {
            return Err(ConfigError::InvalidElectionTimeoutMinMax);
        }
        // Get other values or their defaults.
        let heartbeat_interval = self
            .heartbeat_interval
            .unwrap_or(DEFAULT_HEARTBEAT_INTERVAL);
        let max_payload_entries = self
            .max_payload_entries
            .unwrap_or(DEFAULT_MAX_PAYLOAD_ENTRIES);
        if max_payload_entries == 0 {
            return Err(ConfigError::MaxPayloadEntriesTooSmall);
        }
        let replication_lag_threshold = self
            .replication_lag_threshold
            .unwrap_or(DEFAULT_REPLICATION_LAG_THRESHOLD);
        let snapshot_policy = self.snapshot_policy.unwrap_or_else(SnapshotPolicy::default);
        let snapshot_max_chunk_size = self
            .snapshot_max_chunk_size
            .unwrap_or(DEFAULT_SNAPSHOT_CHUNKSIZE);
        let catch_up_cancellation_policy = self
            .catch_up_cancellation_policy
            .unwrap_or_else(CatchUpCancellationPolicy::default);
        Ok(Config {
            cluster_name: self.cluster_name,
            election_timeout_min,
            election_timeout_max,
            heartbeat_interval,
            max_payload_entries,
            replication_lag_threshold,
            snapshot_policy,
            snapshot_max_chunk_size,
            catch_up_cancellation_policy,
        })
    }
pub fn validate ( self ) -> Result < Config , ConfigError > { // Roll a random election time out based on the configured min & max or their respective defaults. let election_timeout_min = self . election_timeout_min . unwrap_or ( DEFAULT_ELECTION_TIMEOUT_MIN ) ; let election_timeout_max = self . election_timeout_max . unwrap_or ( DEFAULT_ELECTION_TIMEOUT_MAX ) ; if election_timeout_min >= election_timeout_max { return Err ( ConfigError :: InvalidElectionTimeoutMinMax ) ; } // Get other values or their defaults. let heartbeat_interval = self . heartbeat_interval . unwrap_or ( DEFAULT_HEARTBEAT_INTERVAL ) ; let max_payload_entries = self . max_payload_entries . unwrap_or ( DEFAULT_MAX_PAYLOAD_ENTRIES ) ; if max_payload_entries == 0 { return Err ( ConfigError :: MaxPayloadEntriesTooSmall ) ; } let replication_lag_threshold = self . replication_lag_threshold . unwrap_or ( DEFAULT_REPLICATION_LAG_THRESHOLD ) ; let snapshot_policy = self . snapshot_policy . unwrap_or_else ( SnapshotPolicy :: default ) ; let snapshot_max_chunk_size = self . snapshot_max_chunk_size . unwrap_or ( DEFAULT_SNAPSHOT_CHUNKSIZE ) ; let catch_up_cancellation_policy = self . catch_up_cancellation_policy . unwrap_or_else ( CatchUpCancellationPolicy :: default ) ; Ok ( Config { cluster_name : self . cluster_name , election_timeout_min , election_timeout_max , heartbeat_interval , max_payload_entries , replication_lag_threshold , snapshot_policy , snapshot_max_chunk_size , catch_up_cancellation_policy , } ) }
Validate the state of this builder and produce a new `Config` instance if valid.
Validate the state of this builder and produce a new ` Config ` instance if valid .
self
self