pub struct MaskedProvider { /* private fields */ }Expand description
Wraps an AnyProvider so every outbound chat*/chat_with_tools* call masks message
text via an OutboundMasker before delegating to the inner provider.
§Examples
use std::sync::Arc;
use zeph_llm::any::AnyProvider;
use zeph_llm::masking::OutboundMasker;
use zeph_llm::ollama::OllamaProvider;
#[derive(Debug)]
struct UppercaseMasker;
impl OutboundMasker for UppercaseMasker {
fn mask(&self, text: &str) -> Option<String> {
if text.contains("secret") { Some(text.replace("secret", "***")) } else { None }
}
}
let inner = AnyProvider::Ollama(OllamaProvider::new("http://localhost:11434", "m".into(), "e".into()));
let masked = inner.masked(Arc::new(UppercaseMasker));
assert_eq!(masked.name(), "ollama"); // delegation still works transparentlyImplementations§
Source§impl MaskedProvider
impl MaskedProvider
Sourcepub fn new(inner: AnyProvider, masker: Arc<dyn OutboundMasker>) -> Self
pub fn new(inner: AnyProvider, masker: Arc<dyn OutboundMasker>) -> Self
Wrap inner with masker.
Sourcepub fn inner(&self) -> &AnyProvider
pub fn inner(&self) -> &AnyProvider
Return the wrapped provider, discarding the masking layer.
Sourcepub fn applied_count(&self) -> u64
pub fn applied_count(&self) -> u64
Number of outbound calls (across every clone of this wrapper) that had at least one
secret masked. Exposed for the secret_mask_applied observability metric.
Trait Implementations§
Source§impl Clone for MaskedProvider
impl Clone for MaskedProvider
Source§fn clone(&self) -> MaskedProvider
fn clone(&self) -> MaskedProvider
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MaskedProvider
impl Debug for MaskedProvider
Source§impl LlmProvider for MaskedProvider
impl LlmProvider for MaskedProvider
Source§fn context_window(&self) -> Option<usize>
fn context_window(&self) -> Option<usize>
Report the model’s context window size in tokens. Read more
Source§async fn chat(&self, messages: &[Message]) -> Result<String, LlmError>
async fn chat(&self, messages: &[Message]) -> Result<String, LlmError>
Send messages to the LLM and return the assistant response. Read more
Source§async fn chat_with_extras(
&self,
messages: &[Message],
) -> Result<(String, ChatExtras), LlmError>
async fn chat_with_extras( &self, messages: &[Message], ) -> Result<(String, ChatExtras), LlmError>
Send messages and return the assistant response together with per-call extras. Read more
Source§async fn chat_stream(
&self,
messages: &[Message],
) -> Result<ChatStream, LlmError>
async fn chat_stream( &self, messages: &[Message], ) -> Result<ChatStream, LlmError>
Send messages and return a stream of response chunks. Read more
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Whether this provider supports native streaming.
Source§async fn embed(&self, text: &str) -> Result<Vec<f32>, LlmError>
async fn embed(&self, text: &str) -> Result<Vec<f32>, LlmError>
Generate an embedding vector from text. Read more
Source§async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, LlmError>
async fn embed_batch(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>, LlmError>
Embed multiple texts in a single API call. Read more
Source§fn supports_embeddings(&self) -> bool
fn supports_embeddings(&self) -> bool
Whether this provider supports embedding generation.
Source§fn model_identifier(&self) -> &str
fn model_identifier(&self) -> &str
Model identifier string (e.g.
gpt-4o-mini, claude-sonnet-5).
Used by cost-estimation heuristics. Returns "" when not applicable.Source§fn effective_model_identifier(&self) -> &str
fn effective_model_identifier(&self) -> &str
Model identifier that actually served the most recent dispatch. Read more
Source§fn supports_structured_output(&self) -> bool
fn supports_structured_output(&self) -> bool
Whether this provider supports native structured output.
Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Whether this provider supports image input (vision).
Source§fn supports_tool_use(&self) -> bool
fn supports_tool_use(&self) -> bool
Whether this provider supports native
tool_use / function calling. Read moreSource§async fn chat_with_tools(
&self,
messages: &[Message],
tools: &[ToolDefinition],
) -> Result<ChatResponse, LlmError>
async fn chat_with_tools( &self, messages: &[Message], tools: &[ToolDefinition], ) -> Result<ChatResponse, LlmError>
Send messages with tool definitions, returning a structured response. Read more
Source§fn last_cache_usage(&self) -> Option<(u64, u64)>
fn last_cache_usage(&self) -> Option<(u64, u64)>
Return the cache usage from the last API call, if available.
Returns
(cache_creation_tokens, cache_read_tokens).Source§fn last_usage(&self) -> Option<(u64, u64)>
fn last_usage(&self) -> Option<(u64, u64)>
Return token counts from the last API call, if available.
Returns
(input_tokens, output_tokens).Source§fn last_reasoning_tokens(&self) -> Option<u64>
fn last_reasoning_tokens(&self) -> Option<u64>
Return reasoning tokens from the last API call, if the provider reports them. Read more
Source§fn last_ttft_ms(&self) -> Option<u64>
fn last_ttft_ms(&self) -> Option<u64>
Return the time-to-first-byte (milliseconds) of the last API call, if available. Read more
Source§fn debug_request_json(
&self,
messages: &[Message],
tools: &[ToolDefinition],
stream: bool,
) -> Value
fn debug_request_json( &self, messages: &[Message], tools: &[ToolDefinition], stream: bool, ) -> Value
Return the request payload that will be sent to the provider, for debug dumps. Read more
Source§fn take_compaction_summary(&self) -> Option<String>
fn take_compaction_summary(&self) -> Option<String>
Return the compaction summary from the most recent API call, if a server-side
compaction occurred (Claude compact-2026-01-12 beta). Clears the stored value.
Source§fn list_models(&self) -> Vec<String>
fn list_models(&self) -> Vec<String>
Return the list of model identifiers this provider can serve.
Default: empty (provider does not advertise models).
Auto Trait Implementations§
impl !RefUnwindSafe for MaskedProvider
impl !UnwindSafe for MaskedProvider
impl Freeze for MaskedProvider
impl Send for MaskedProvider
impl Sync for MaskedProvider
impl Unpin for MaskedProvider
impl UnsafeUnpin for MaskedProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> LlmProviderDyn for T
impl<T> LlmProviderDyn for T
Source§fn context_window(&self) -> Option<usize>
fn context_window(&self) -> Option<usize>
Report the model’s context window size in tokens.
None if unknown.Source§fn chat<'a>(
&'a self,
messages: &'a [Message],
) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'a>>
fn chat<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<String, LlmError>> + Send + 'a>>
Send messages to the LLM and return the assistant response. Read more
Source§fn chat_stream<'a>(
&'a self,
messages: &'a [Message],
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>, LlmError>> + Send + 'a>>
fn chat_stream<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamChunk, LlmError>> + Send>>, LlmError>> + Send + 'a>>
Send messages and return a stream of response chunks. Read more
Source§fn supports_streaming(&self) -> bool
fn supports_streaming(&self) -> bool
Whether this provider supports native streaming.
Source§fn embed<'a>(
&'a self,
text: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, LlmError>> + Send + 'a>>
fn embed<'a>( &'a self, text: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Vec<f32>, LlmError>> + Send + 'a>>
Generate an embedding vector from text. Read more
Source§fn embed_batch<'a>(
&'a self,
texts: &'a [&'a str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, LlmError>> + Send + 'a>>
fn embed_batch<'a>( &'a self, texts: &'a [&'a str], ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<f32>>, LlmError>> + Send + 'a>>
Embed multiple texts in a single API call. Read more
Source§fn supports_embeddings(&self) -> bool
fn supports_embeddings(&self) -> bool
Whether this provider supports embedding generation.
Source§fn model_identifier(&self) -> &str
fn model_identifier(&self) -> &str
Model identifier string (e.g.
gpt-4o-mini, claude-sonnet-5).Source§fn effective_model_identifier(&self) -> &str
fn effective_model_identifier(&self) -> &str
Model identifier that actually served the most recent dispatch. See
LlmProvider::effective_model_identifier for the full contract.Source§fn supports_vision(&self) -> bool
fn supports_vision(&self) -> bool
Whether this provider supports image input (vision).
Source§fn supports_tool_use(&self) -> bool
fn supports_tool_use(&self) -> bool
Whether this provider supports native
tool_use / function calling.Source§fn chat_with_tools<'a>(
&'a self,
messages: &'a [Message],
tools: &'a [ToolDefinition],
) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
fn chat_with_tools<'a>( &'a self, messages: &'a [Message], tools: &'a [ToolDefinition], ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmError>> + Send + 'a>>
Send messages with tool definitions, returning a structured response. Read more
Source§fn last_cache_usage(&self) -> Option<(u64, u64)>
fn last_cache_usage(&self) -> Option<(u64, u64)>
Return the cache usage from the last API call, if available.
Returns
(cache_creation_tokens, cache_read_tokens).Source§fn last_usage(&self) -> Option<(u64, u64)>
fn last_usage(&self) -> Option<(u64, u64)>
Return token counts from the last API call, if available.
Returns
(input_tokens, output_tokens).Source§fn take_compaction_summary(&self) -> Option<String>
fn take_compaction_summary(&self) -> Option<String>
Return the compaction summary from the most recent API call, if available.
Source§fn chat_with_extras<'a>(
&'a self,
messages: &'a [Message],
) -> Pin<Box<dyn Future<Output = Result<(String, ChatExtras), LlmError>> + Send + 'a>>
fn chat_with_extras<'a>( &'a self, messages: &'a [Message], ) -> Pin<Box<dyn Future<Output = Result<(String, ChatExtras), LlmError>> + Send + 'a>>
Send messages and return the assistant response together with per-call extras. Read more
Source§fn debug_request_json(
&self,
messages: &[Message],
tools: &[ToolDefinition],
stream: bool,
) -> Value
fn debug_request_json( &self, messages: &[Message], tools: &[ToolDefinition], stream: bool, ) -> Value
Return the request payload that will be sent to the provider, for debug dumps.
Source§fn list_models(&self) -> Vec<String>
fn list_models(&self) -> Vec<String>
Return the list of model identifiers this provider can serve.
Source§fn supports_structured_output(&self) -> bool
fn supports_structured_output(&self) -> bool
Whether this provider supports native structured output.