pub fn memory_config_check(
memory_config: &MemoryConfig,
) -> Result<Option<(String, u64)>, MemoryConfigError>Expand description
Checks a specified environment variable against a configured minimum and maximum values.
This function is used at application startup to verify that a system memory
setting (MALLOC_ARENA_MAX) is within a safe and expected range.
§Arguments
memory_config- A reference to theMemoryConfigstruct containing the check parameters (active flag, variable name, min/max values).
§Returns
A Result containing an Option on success:
Ok(Some((String, u64))): If the check is active and the environment variable’s value is within the configured bounds. The tuple contains the variable’s name and its parsed value.Ok(None): If the check is configured to be inactive (active: false).
§Errors
Returns a MemoryConfigError if the check is active and any validation step fails:
MemoryConfigError::ConfigEnvVarNameEmpty: Ifactiveis true, but theenv_variable_namein the configuration is empty.MemoryConfigError::EnvVarNotSet: If the specified environment variable is not set in the current environment.MemoryConfigError::EnvVarParseError: If the value of the environment variable cannot be parsed into au64integer.MemoryConfigError::EnvVarValueTooLow: If the parsed value is less than the configuredenv_variable_min_val.MemoryConfigError::EnvVarValueTooHigh: If the parsed value is greater than the configuredenv_variable_max_val.