pub struct Cache<Renderer>where
Renderer: Renderer,{ /* private fields */ }
Available on crate feature
geometry
only.Expand description
A simple cache that stores generated geometry to avoid recomputation.
A Cache
will not redraw its geometry unless the dimensions of its layer
change or it is explicitly cleared.
Implementations§
Source§impl<Renderer> Cache<Renderer>where
Renderer: Renderer,
impl<Renderer> Cache<Renderer>where
Renderer: Renderer,
Sourcepub fn with_group(group: Group) -> Self
pub fn with_group(group: Group) -> Self
Sourcepub fn draw(
&self,
renderer: &Renderer,
bounds: Size,
draw_fn: impl FnOnce(&mut Frame<Renderer>),
) -> Renderer::Geometry
pub fn draw( &self, renderer: &Renderer, bounds: Size, draw_fn: impl FnOnce(&mut Frame<Renderer>), ) -> Renderer::Geometry
Draws geometry using the provided closure and stores it in the
Cache
.
The closure will only be called when
- the bounds have changed since the previous draw call.
- the
Cache
is empty or has been explicitly cleared.
Otherwise, the previously stored geometry will be returned. The
Cache
is not cleared in this case. In other words, it will keep
returning the stored geometry if needed.
Trait Implementations§
Auto Trait Implementations§
impl<Renderer> !Freeze for Cache<Renderer>
impl<Renderer> !RefUnwindSafe for Cache<Renderer>
impl<Renderer> Send for Cache<Renderer>
impl<Renderer> !Sync for Cache<Renderer>
impl<Renderer> Unpin for Cache<Renderer>
impl<Renderer> UnwindSafe for Cache<Renderer>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian()
.