fn apply_prefix_suffix<'a>(
        &self,
        content: &'a str,
        char_count: usize,
        prefix_limit: usize,
        suffix_limit: usize,
    ) -> ClipperResult<'a> {
        // If the combined limits exceed or equal content length, return the whole
        // content
        if prefix_limit + suffix_limit >= char_count {
            return ClipperResult { prefix: None, suffix: None, actual: content };
        }

        // Find the byte index for prefix
        let prefix_end_idx = content
            .char_indices()
            .nth(prefix_limit)
            .map_or(content.len(), |(idx, _)| idx);

        // Find the byte index for suffix
        let suffix_start_idx = content
            .char_indices()
            .nth(char_count - suffix_limit)
            .map_or(0, |(idx, _)| idx);

        ClipperResult {
            prefix: Some(0..prefix_end_idx),
            suffix: Some(suffix_start_idx..content.len()),
            actual: content,
        }
    }
Helper method to truncate content from both prefix and suffix
crates/forge_services/src/clipper.rs