Skip to content

Add convenience function set_if on ClientConfig#667

Open
theelderbeever wants to merge 1 commit intofede1024:masterfrom
theelderbeever:client-config-convenience-function-set-if
Open

Add convenience function set_if on ClientConfig#667
theelderbeever wants to merge 1 commit intofede1024:masterfrom
theelderbeever:client-config-convenience-function-set-if

Conversation

@theelderbeever
Copy link
Copy Markdown

@theelderbeever theelderbeever commented Apr 1, 2024

Adds a simple function ClientConfig.set_if that wraps ClientConfig.set to allow for passing values that are options. This is helpful for configuring clients dynamically via config files that may or may not have values set.

// Such a value could be read from a config file if the user wanted to set it otherwise, it would read in as `None`.
let sasl_mechanism = Some("PLAINTEXT");

let config = ClientConfig::new()
    .set_if(
        "sasl.mechanism", sasl_mechanism,
    );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant