Struct LiveReloadLayer

Source
pub struct LiveReloadLayer<ReqPred = Always, ResPred = ContentTypeStartsWith<&'static str>> { /* private fields */ }
Expand description

Layer to apply LiveReload middleware.

Implementations§

Source§

impl LiveReloadLayer

Source

pub fn new() -> Self

Create a new LiveReloadLayer with the default prefix for internal routes.

The default prefix is deliberately long and specific to avoid any accidental collisions with the wrapped service.

Source

pub fn with_custom_prefix<P: Into<String>>(prefix: P) -> Self

👎Deprecated since 0.8.0: please use LiveReloadLayer::new and custom_prefix instead

Create a new LiveReloadLayer with a custom prefix.

Source§

impl<ReqPred, ResPred> LiveReloadLayer<ReqPred, ResPred>

Source

pub fn custom_prefix<P: Into<String>>(self, prefix: P) -> Self

Set a custom prefix for internal routes for the given LiveReloadLayer.

Source

pub fn request_predicate<Body, P: Predicate<Request<Body>>>( self, predicate: P, ) -> LiveReloadLayer<P, ResPred>

Set a custom predicate for requests that should have their response HTML injected with live-reload logic.

Note that this predicate is applied in addition to the default response predicate, which makes sure that only HTML responses are injected.

Also see predicate for pre-defined predicates and predicate::Predicate for how to implement your own predicates.

Source

pub fn response_predicate<Body, P: Predicate<Response<Body>>>( self, predicate: P, ) -> LiveReloadLayer<ReqPred, P>

Set a custom predicate for responses that should be injected with live-reload logic.

Note that this predicate is applied instead of the default response predicate, which would make sure that only HTML responses are injected. However, even with a custom predicate only responses without a custom encoding i.e. no Content-Encoding header can and will be injected.

Also see predicate for pre-defined predicates and predicate::Predicate for how to implement your own predicates.

Source

pub fn reload_interval(self, interval: Duration) -> Self

Set a custom retry interval for the live-reload logic.

Source

pub fn reloader(&self) -> Reloader

Return a manual Reloader trigger for the given LiveReloadLayer.

Trait Implementations§

Source§

impl<ReqPred: Clone, ResPred: Clone> Clone for LiveReloadLayer<ReqPred, ResPred>

Source§

fn clone(&self) -> LiveReloadLayer<ReqPred, ResPred>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<ReqPred: Debug, ResPred: Debug> Debug for LiveReloadLayer<ReqPred, ResPred>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LiveReloadLayer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<S, ReqPred: Copy, ResPred: Copy> Layer<S> for LiveReloadLayer<ReqPred, ResPred>

Source§

type Service = LiveReload<S, ReqPred, ResPred>

The wrapped service
Source§

fn layer(&self, inner: S) -> Self::Service

Wrap the given service with the middleware, returning a new service that has been decorated with the middleware.

Auto Trait Implementations§

§

impl<ReqPred, ResPred> Freeze for LiveReloadLayer<ReqPred, ResPred>
where ReqPred: Freeze, ResPred: Freeze,

§

impl<ReqPred, ResPred> RefUnwindSafe for LiveReloadLayer<ReqPred, ResPred>
where ReqPred: RefUnwindSafe, ResPred: RefUnwindSafe,

§

impl<ReqPred, ResPred> Send for LiveReloadLayer<ReqPred, ResPred>
where ReqPred: Send, ResPred: Send,

§

impl<ReqPred, ResPred> Sync for LiveReloadLayer<ReqPred, ResPred>
where ReqPred: Sync, ResPred: Sync,

§

impl<ReqPred, ResPred> Unpin for LiveReloadLayer<ReqPred, ResPred>
where ReqPred: Unpin, ResPred: Unpin,

§

impl<ReqPred, ResPred> UnwindSafe for LiveReloadLayer<ReqPred, ResPred>
where ReqPred: UnwindSafe, ResPred: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.