Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add convenience function set_if on ClientConfig #667

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

theelderbeever
Copy link

@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