Skip to main content

Cache

Struct Cache 

Source
pub struct Cache { /* private fields */ }

Implementations§

Source§

impl Cache

Source

pub fn new(ttl: Duration, body_cap: usize) -> Self

Source

pub fn has_listing(&self, dir: &str) -> bool

Is there a listing for this directory that is still inside its TTL?

Distinct from attrs_of returning None, which cannot tell “no listing” from “listed, and the name is not in it”. The origin layer needs that difference: the second is a 404 it can answer locally, the first is a fetch.

Source

pub fn attrs_of(&self, dir: &str, name: &str) -> Option<Attrs>

Attrs for one entry of a fresh listing. Attrs is Copy, so this does not clone the map.

Source

pub fn listing_entries(&self, dir: &str) -> Option<Vec<Entry>>

A fresh listing as entries, for rendering a directory index.

Unlike attrs_of this clones, because an autoindex needs every name anyway and holding the lock across the render would block every other request.

Source

pub fn put_listing(&self, dir: &str, entries: &[Entry])

Source

pub fn forget_listing(&self, dir: &str)

Forget a listing so the next request refetches it.

Called when a fetch contradicts the listing: a file the listing promised, and the remote refused. Keeping a listing that has been proven wrong would serve the same wrong answer for a whole TTL.

Source

pub fn body(&self, path: &str, attrs: &Attrs) -> Option<Bytes>

Source

pub fn put_body(&self, path: &str, attrs: &Attrs, body: Bytes)

Trait Implementations§

Source§

impl Default for Cache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for Cache

§

impl RefUnwindSafe for Cache

§

impl Send for Cache

§

impl Sync for Cache

§

impl Unpin for Cache

§

impl UnsafeUnpin for Cache

§

impl UnwindSafe for Cache

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.