#[non_exhaustive]pub struct Htmx {
pub request: bool,
pub boosted: bool,
pub target: Option<String>,
pub trigger: Option<String>,
pub current_url: Option<String>,
}Expand description
What HTMX told us about the current request.
async fn index(htmx: Htmx) -> View {
let page = view("products/index.html", context! {});
if htmx.request { page.fragment("list") } else { page }
}Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.request: boolThe request was made by HTMX (HX-Request).
boosted: boolThe request comes from an hx-boost link or form, which expects a full page.
target: Option<String>The id of the target element (HX-Target).
trigger: Option<String>The id of the element that triggered the request (HX-Trigger).
current_url: Option<String>The browser’s current URL (HX-Current-URL).
Implementations§
Source§impl Htmx
impl Htmx
Sourcepub fn from_headers(headers: &HeaderMap) -> Self
pub fn from_headers(headers: &HeaderMap) -> Self
Reads the htmx request headers.
Sourcepub fn redirect(&self, to: &str) -> Response
pub fn redirect(&self, to: &str) -> Response
Goes to to after a form post: HX-Redirect for htmx requests (a
full page load in the browser), a 303 See Other otherwise.
Sourcepub fn wants_fragment(&self) -> bool
pub fn wants_fragment(&self) -> bool
An HTMX request that wants a fragment rather than a full page.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Htmx
impl RefUnwindSafe for Htmx
impl Send for Htmx
impl Sync for Htmx
impl Unpin for Htmx
impl UnsafeUnpin for Htmx
impl UnwindSafe for Htmx
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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<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