Skip to main content

graphify_core/
lib.rs

1pub mod confidence;
2pub mod error;
3pub mod graph;
4pub mod id;
5pub mod model;
6
7/// Maximum bytes for a single filename component (excluding extension).
8/// macOS HFS+/APFS limit is 255 bytes per component; we reserve 15 for extension + safety.
9pub const MAX_FILENAME_BYTES: usize = 240;
10
11/// Truncate a string to at most `max_bytes` bytes while preserving UTF-8 validity.
12pub fn truncate_to_bytes(s: &str, max_bytes: usize) -> &str {
13    if s.len() <= max_bytes {
14        return s;
15    }
16    let mut end = max_bytes;
17    while end > 0 && !s.is_char_boundary(end) {
18        end -= 1;
19    }
20    &s[..end]
21}