Trait ariadne::Cache

source ·
pub trait Cache<Id: ?Sized> {
    type Storage: AsRef<str>;

    // Required methods
    fn fetch(
        &mut self,
        id: &Id
    ) -> Result<&Source<Self::Storage>, Box<dyn Debug + '_>>;
    fn display<'a>(&self, id: &'a Id) -> Option<Box<dyn Display + 'a>>;
}
Expand description

A trait implemented by Source caches.

Required Associated Types§

source

type Storage: AsRef<str>

The type used to store the string data for this cache.

Alternative types other than String can be used, but at the moment, the storage must be contiguous. A primary use case for this is to use a reference-counted string instead of copying the whole contents into a Source.

Required Methods§

source

fn fetch( &mut self, id: &Id ) -> Result<&Source<Self::Storage>, Box<dyn Debug + '_>>

Fetch the Source identified by the given ID, if possible.

source

fn display<'a>(&self, id: &'a Id) -> Option<Box<dyn Display + 'a>>

Display the given ID. as a single inline value.

This function may make use of attributes from the Fmt trait.

Implementations on Foreign Types§

source§

impl<'b, C: Cache<Id>, Id: ?Sized> Cache<Id> for &'b mut C

§

type Storage = <C as Cache<Id>>::Storage

source§

fn fetch( &mut self, id: &Id ) -> Result<&Source<Self::Storage>, Box<dyn Debug + '_>>

source§

fn display<'a>(&self, id: &'a Id) -> Option<Box<dyn Display + 'a>>

source§

impl<C: Cache<Id>, Id: ?Sized> Cache<Id> for Box<C>

§

type Storage = <C as Cache<Id>>::Storage

source§

fn fetch( &mut self, id: &Id ) -> Result<&Source<Self::Storage>, Box<dyn Debug + '_>>

source§

fn display<'a>(&self, id: &'a Id) -> Option<Box<dyn Display + 'a>>

source§

impl<I: AsRef<str>, Id: Display + Eq> Cache<Id> for (Id, Source<I>)

§

type Storage = I

source§

fn fetch(&mut self, id: &Id) -> Result<&Source<I>, Box<dyn Debug + '_>>

source§

fn display<'a>(&self, id: &'a Id) -> Option<Box<dyn Display + 'a>>

Implementors§

source§

impl Cache<Path> for FileCache

source§

impl<I: AsRef<str>> Cache<()> for Source<I>

§

type Storage = I

source§

impl<Id: Display + Hash + PartialEq + Eq + Clone, F, I> Cache<Id> for FnCache<Id, F, I>
where I: AsRef<str>, F: for<'a> FnMut(&'a Id) -> Result<I, Box<dyn Debug>>,

§

type Storage = I