pub trait TokenCounting: Send + Sync {
// Required methods
fn count_tokens(&self, text: &str) -> usize;
fn count_tool_schema_tokens(&self, schema: &Value) -> usize;
}Expand description
Minimal token-counting interface used by zeph-context for budget enforcement.
Defined here in Layer 0 so zeph-context can accept a &dyn TokenCounting
without importing zeph-memory. zeph-memory::TokenCounter implements this trait.
Required Methods§
Sourcefn count_tokens(&self, text: &str) -> usize
fn count_tokens(&self, text: &str) -> usize
Count tokens in a plain text string.
Sourcefn count_tool_schema_tokens(&self, schema: &Value) -> usize
fn count_tool_schema_tokens(&self, schema: &Value) -> usize
Count tokens for a JSON schema value (tool definitions).