scv-client 0.3.0

Local daemon discovery and management client for SCV
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Byte-bounded text, for limits that count bytes on the wire or on disk.

/// The longest prefix of `value` that fits in `max_bytes` without splitting
/// a character.
pub fn utf8_prefix(value: &str, max_bytes: usize) -> &str {
    if value.len() <= max_bytes {
        return value;
    }
    let mut end = max_bytes;
    while !value.is_char_boundary(end) {
        end -= 1;
    }
    &value[..end]
}

#[cfg(test)]
mod tests;