pub struct IncrementalRenderer { /* private fields */ }
Expand description
An incremental renderer.
Implementations§
Source§impl IncrementalRenderer
impl IncrementalRenderer
Sourcepub fn builder() -> IncrementalRendererConfig
pub fn builder() -> IncrementalRendererConfig
Create a new incremental renderer builder.
Sourcepub fn invalidate(&mut self, route: &str)
pub fn invalidate(&mut self, route: &str)
Remove a route from the cache.
Sourcepub fn invalidate_all(&mut self)
pub fn invalidate_all(&mut self)
Remove all routes from the cache.
Sourcepub fn cache(
&mut self,
route: String,
html: impl Into<Vec<u8>>,
) -> Result<RenderFreshness, IncrementalRendererError>
pub fn cache( &mut self, route: String, html: impl Into<Vec<u8>>, ) -> Result<RenderFreshness, IncrementalRendererError>
Cache a rendered response.
let route = "/index".to_string();
let response = b"<html><body>Hello world</body></html>";
renderer.cache(route, response).unwrap();
Sourcepub fn get<'a>(
&'a mut self,
route: &str,
) -> Result<Option<CachedRender<'a>>, IncrementalRendererError>
pub fn get<'a>( &'a mut self, route: &str, ) -> Result<Option<CachedRender<'a>>, IncrementalRendererError>
Try to get a cached response for a route.
let route = "/index";
let response = renderer.get(route).unwrap();
assert_eq!(response.unwrap().response, b"<html><body>Hello world</body></html>");
If the route is not cached, None
is returned.
let route = "/index";
let response = renderer.get(route).unwrap();
assert!(response.is_none());
Auto Trait Implementations§
impl Freeze for IncrementalRenderer
impl !RefUnwindSafe for IncrementalRenderer
impl Send for IncrementalRenderer
impl Sync for IncrementalRenderer
impl Unpin for IncrementalRenderer
impl !UnwindSafe for IncrementalRenderer
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