Skip to main content

TokenCounter

Trait TokenCounter 

Source
pub trait TokenCounter: Send + Sync {
    // Required methods
    fn count(&self, text: &str) -> usize;
    fn backend_name(&self) -> &'static str;
}
Expand description

Abstraction over token counting backends.

Required Methods§

Source

fn count(&self, text: &str) -> usize

Return an estimated (or exact) token count for text.

Source

fn backend_name(&self) -> &'static str

Return a human-readable name for this backend.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§