r3bl_tui 0.7.2

TUI library to build modern apps inspired by React, Elm, with Flexbox, CSS, editor component, emoji support, and more
Documentation
/*
 *   Copyright (c) 2024-2025 R3BL LLC
 *   All rights reserved.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

use miette::IntoDiagnostic;

mod constants {
    pub const USER_AGENT: &str = "scripting.rs/1.0";
}

/// # Errors
///
/// Returns an error if:
/// - The HTTP client builder fails to build
/// - TLS backend initialization fails
pub fn create_client_with_user_agent(
    user_agent: Option<&str>,
) -> miette::Result<reqwest::Client> {
    let it = reqwest::Client::builder()
        .user_agent(user_agent.map_or_else(
            /* none */ || constants::USER_AGENT.to_owned(),
            /* some */ ToOwned::to_owned,
        ))
        .build();
    it.into_diagnostic()
}