forgecode / crates /forge_app /src /truncation /truncate_fetch.rs
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
767452b verified
Raw History Blame Contribute Delete
593 Bytes
/// 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 }
}