Struct spirit::fragment::driver::CacheSimilar [−][src]
Expand description
A Driver
that caches both created Resource
s and their Seed
s to create as little as
possible.
It uses the Comparable
trait to decide if it needs to create the Resource
complete from
scratch, if it can reuse the old Seed
or if it can even keep the old instance. This is a
good driver for cases where the Seed
is some kind of unique resource and changing the
resource by creating a completely new instance while the old one existed wouldn’t work. An
example of this is the bound ports on listening sockets ‒ while we might want to attach
different configuration to the same socket, opening a new socket with the same port would not
work. Therefore, the socket is somewhere within the Seed
and it is reused if the port
doesn’t change.
Trait Implementations
impl<F> Driver<F> for CacheSimilar<F> where
F: Debug + Fragment + ToOwned + Comparable<<F as ToOwned>::Owned>,
impl<F> Driver<F> for CacheSimilar<F> where
F: Debug + Fragment + ToOwned + Comparable<<F as ToOwned>::Owned>,
type SubFragment = F
type SubFragment = F
fn instructions<T, I>(
&mut self,
fragment: &F,
transform: &mut T,
name: &'static str
) -> Result<Vec<Instruction<T::OutputResource>>, Vec<AnyError>> where
T: Transformation<F::Resource, I, F>,
fn instructions<T, I>(
&mut self,
fragment: &F,
transform: &mut T,
name: &'static str
) -> Result<Vec<Instruction<T::OutputResource>>, Vec<AnyError>> where
T: Transformation<F::Resource, I, F>,
Issues the instructions how to transition to the new fragment. Read more
Call to this method informs the Driver
that the instructions returned by the last call
to instructions
were not followed and were dropped. Read more
Call to this method informs the Driver
that the instructions returned by the last call
to instructions
were followed and the changes have taken place. Read more