Skip to main content

HandleHit

Trait HandleHit 

Source
pub trait HandleHit {
    // Required methods
    fn read_body<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn finish<'life0, 'life1, 'async_trait>(
        self: Box<Self>,
        storage: &'static (dyn Storage + Sync),
        key: &'life0 CacheKey,
        trace: &'life1 SpanHandle,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn as_any(&self) -> &(dyn Any + Send + Sync);
    fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync);

    // Provided methods
    fn can_seek(&self) -> bool { ... }
    fn can_seek_multipart(&self) -> bool { ... }
    fn seek(&mut self, _start: usize, _end: Option<usize>) -> Result<()> { ... }
    fn seek_multipart(&mut self, start: usize, end: Option<usize>) -> Result<()> { ... }
    fn should_count_access(&self) -> bool { ... }
    fn get_eviction_weight(&self) -> usize { ... }
}
Expand description

Cache hit handling trait

Required Methods§

Source

fn read_body<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read cached body

Return None when no more body to read.

Source

fn finish<'life0, 'life1, 'async_trait>( self: Box<Self>, storage: &'static (dyn Storage + Sync), key: &'life0 CacheKey, trace: &'life1 SpanHandle, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Finish the current cache hit

Source

fn as_any(&self) -> &(dyn Any + Send + Sync)

Helper function to cast the trait object to concrete types

Source

fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync)

Helper function to cast the trait object to concrete types

Provided Methods§

Source

fn can_seek(&self) -> bool

Whether this storage allows seeking to a certain range of body for single ranges.

Source

fn can_seek_multipart(&self) -> bool

Whether this storage allows seeking to a certain range of body for multipart ranges.

By default uses the can_seek implementation.

Source

fn seek(&mut self, _start: usize, _end: Option<usize>) -> Result<()>

Try to seek to a certain range of the body for single ranges.

end: None means to read to the end of the body.

Source

fn seek_multipart(&mut self, start: usize, end: Option<usize>) -> Result<()>

Try to seek to a certain range of the body for multipart ranges.

Works in an identical manner to seek().

end: None means to read to the end of the body.

By default uses the seek implementation, but hit handlers may customize the implementation specifically to anticipate multipart requests.

Source

fn should_count_access(&self) -> bool

Should we count this hit handler instance as an access in the eviction manager.

Defaults to returning true to track all cache hits as accesses. Customize this if certain hits should not affect the eviction system’s view of the asset.

Source

fn get_eviction_weight(&self) -> usize

Returns the weight of the current cache hit asset to report to the eviction manager.

This allows the eviction system to initialize a weight for the asset, in case it is not already tracking it (e.g. storage is out of sync with the eviction manager).

Defaults to 0.

Implementors§