File size: 593 Bytes
767452b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /// Represents the result of fetch content truncation
#[derive(Debug)]
pub struct TruncatedFetchOutput {
pub content: String,
}
/// Truncates fetch content based on character limit
pub fn truncate_fetch_content(content: &str, truncation_limit: usize) -> TruncatedFetchOutput {
let original_length = content.len();
let is_truncated = original_length > truncation_limit;
let truncated_content = if is_truncated {
content.chars().take(truncation_limit).collect()
} else {
content.to_string()
};
TruncatedFetchOutput { content: truncated_content }
}
|