pub struct RateLimit { /* private fields */ }Implementations§
Trait Implementations§
Source§impl Extension for RateLimit
impl Extension for RateLimit
Source§fn on_request(
&self,
ctx: &RequestContext,
) -> BoxFuture<'_, Result<(), ExtensionError>>
fn on_request( &self, ctx: &RequestContext, ) -> BoxFuture<'_, Result<(), ExtensionError>>
Called post-auth, pre-dispatch. Return
Err to short-circuit the pipeline
(no provider call, no further extensions run).Source§fn on_response(
&self,
ctx: &RequestContext,
_request: &ChatCompletionRequest,
response: &ChatCompletionResponse,
) -> BoxFuture<'_, ()>
fn on_response( &self, ctx: &RequestContext, _request: &ChatCompletionRequest, response: &ChatCompletionResponse, ) -> BoxFuture<'_, ()>
Called after a non-streaming chat completion response arrives from the provider.
Source§fn on_chunk(
&self,
ctx: &RequestContext,
chunk: &ChatCompletionChunk,
) -> BoxFuture<'_, ()>
fn on_chunk( &self, ctx: &RequestContext, chunk: &ChatCompletionChunk, ) -> BoxFuture<'_, ()>
Called once per SSE chunk during a streaming response, before serialization.
Source§fn storage_key(&self, suffix: &[u8]) -> Vec<u8> ⓘ
fn storage_key(&self, suffix: &[u8]) -> Vec<u8> ⓘ
Build a full storage key by prepending this extension’s prefix to
suffix.Source§fn on_cache_lookup(
&self,
_request: &ChatCompletionRequest,
) -> Pin<Box<dyn Future<Output = Option<ChatCompletionResponse>> + Send + '_>>
fn on_cache_lookup( &self, _request: &ChatCompletionRequest, ) -> Pin<Box<dyn Future<Output = Option<ChatCompletionResponse>> + Send + '_>>
Check for a cached response before provider dispatch. Return
Some to
skip the provider call entirely. Called for non-streaming requests only.Auto Trait Implementations§
impl Freeze for RateLimit
impl !RefUnwindSafe for RateLimit
impl Send for RateLimit
impl Sync for RateLimit
impl Unpin for RateLimit
impl UnsafeUnpin for RateLimit
impl !UnwindSafe for RateLimit
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