pub struct IncrementalRenderer { /* private fields */ }
Available on crate feature
server
only.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
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.