box-open-sdk 0.4.1

Box API client for Rust (open source, community, punk rock) — typed models, async managers, and a reqwest runtime with retry, backoff, and token refresh.
Documentation
// Code generated by box-gantry. DO NOT EDIT.

/// Comma-join a slice into a query value, converting each element with `f`.
pub(crate) fn join<T>(items: &[T], f: impl Fn(&T) -> String) -> String {
    items.iter().map(f).collect::<Vec<_>>().join(",")
}

/// Percent-encode a value, leaving RFC 3986 unreserved characters as-is.
pub(crate) fn path_escape(value: &str) -> String {
    let mut out = String::with_capacity(value.len());
    for &byte in value.as_bytes() {
        match byte {
            b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'.' | b'_' | b'~' => {
                out.push(byte as char);
            }
            _ => {
                out.push('%');
                out.push_str(&format!("{byte:02X}"));
            }
        }
    }
    out
}

/// application/x-www-form-urlencoded body from key/value pairs (the OAuth2
/// token endpoints): each key and value percent-encoded, joined by `&`.
pub(crate) fn form_encode(pairs: &[(&str, String)]) -> String {
    let mut out = String::new();
    for (index, (key, value)) in pairs.iter().enumerate() {
        if index > 0 {
            out.push('&');
        }
        out.push_str(&path_escape(key));
        out.push('=');
        out.push_str(&path_escape(value));
    }
    out
}