pub trait TokenCounter: Send + Sync {
// Required methods
fn count(&self, text: &str) -> u32;
fn truncate<'a>(&self, text: &'a str, max_tokens: u32) -> &'a str;
}Expand description
Token counting and truncation interface. Implementations must be deterministic and must never panic on any valid UTF-8 input.
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".