mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-11-23 20:02:50 +01:00
Formatting
This commit is contained in:
parent
9d559d0041
commit
29dbadc8bc
3 changed files with 23 additions and 18 deletions
|
@ -42,8 +42,8 @@ where
|
||||||
/// This is set on every request made by htmx itself. As its name implies, it
|
/// This is set on every request made by htmx itself. As its name implies, it
|
||||||
/// just contains the current url.
|
/// just contains the current url.
|
||||||
///
|
///
|
||||||
/// This extractor will always return a value. If the header is not present, or extractor fails to parse the url
|
/// This extractor will always return a value. If the header is not present, or
|
||||||
/// it will return `None`.
|
/// extractor fails to parse the url it will return `None`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct HxCurrentUrl(pub Option<http::Uri>);
|
pub struct HxCurrentUrl(pub Option<http::Uri>);
|
||||||
|
|
||||||
|
@ -70,8 +70,8 @@ where
|
||||||
|
|
||||||
/// The `HX-History-Restore-Request` header.
|
/// The `HX-History-Restore-Request` header.
|
||||||
///
|
///
|
||||||
/// This extractor will always return a value. If the header is not present,
|
/// This extractor will always return a value. If the header is not present, it
|
||||||
/// it will return `false`.
|
/// will return `false`.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct HxHistoryRestoreRequest(pub bool);
|
pub struct HxHistoryRestoreRequest(pub bool);
|
||||||
|
|
||||||
|
@ -148,8 +148,8 @@ where
|
||||||
/// The `HX-Target` header.
|
/// The `HX-Target` header.
|
||||||
///
|
///
|
||||||
/// This is set when a request is made from an element that has the `hx-target`
|
/// This is set when a request is made from an element that has the `hx-target`
|
||||||
/// attribute set. The value will contain the target element's id. If the
|
/// attribute set. The value will contain the target element's id. If the id
|
||||||
/// id does not exist on the page, the value will be None.
|
/// does not exist on the page, the value will be None.
|
||||||
///
|
///
|
||||||
/// This extractor will always return a value. If the header is not present, it
|
/// This extractor will always return a value. If the header is not present, it
|
||||||
/// will return `None`.
|
/// will return `None`.
|
||||||
|
@ -206,8 +206,8 @@ where
|
||||||
/// The `HX-Trigger` header.
|
/// The `HX-Trigger` header.
|
||||||
///
|
///
|
||||||
/// This is set when a request is made from an element that has the `hx-trigger`
|
/// This is set when a request is made from an element that has the `hx-trigger`
|
||||||
/// attribute set. The value will contain the trigger element's id. If the
|
/// attribute set. The value will contain the trigger element's id. If the id
|
||||||
/// id does not exist on the page, the value will be None.
|
/// does not exist on the page, the value will be None.
|
||||||
///
|
///
|
||||||
/// This extractor will always return a value. If the header is not present, it
|
/// This extractor will always return a value. If the header is not present, it
|
||||||
/// will return `None`.
|
/// will return `None`.
|
||||||
|
|
|
@ -147,7 +147,8 @@ impl IntoResponseParts for HxLocation {
|
||||||
/// - `swap` - how the response will be swapped in relative to the target
|
/// - `swap` - how the response will be swapped in relative to the target
|
||||||
/// - `values` - values to submit with the request
|
/// - `values` - values to submit with the request
|
||||||
/// - `headers` - headers to submit with the request
|
/// - `headers` - headers to submit with the request
|
||||||
/// - `select` - allows you to select the content you want swapped from a response
|
/// - `select` - allows you to select the content you want swapped from a
|
||||||
|
/// response
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
#[cfg_attr(feature = "unstable", doc(cfg(feature = "serde")))]
|
#[cfg_attr(feature = "unstable", doc(cfg(feature = "serde")))]
|
||||||
#[derive(Debug, Clone, serde::Serialize, Default)]
|
#[derive(Debug, Clone, serde::Serialize, Default)]
|
||||||
|
|
|
@ -103,9 +103,9 @@ pub enum TriggerMode {
|
||||||
|
|
||||||
/// The `HX-Trigger*` header.
|
/// The `HX-Trigger*` header.
|
||||||
///
|
///
|
||||||
/// Allows you to trigger client-side events.
|
/// Allows you to trigger client-side events. Corresponds to `HX-Trigger`,
|
||||||
/// Corresponds to `HX-Trigger`, `HX-Trigger-After-Settle` and `HX-Trigger-After-Swap` headers.
|
/// `HX-Trigger-After-Settle` and `HX-Trigger-After-Swap` headers. To change
|
||||||
/// To change when events trigger use appropriate `mode`.
|
/// when events trigger use appropriate `mode`.
|
||||||
///
|
///
|
||||||
/// Will fail if the supplied events contain or produce characters that are not
|
/// Will fail if the supplied events contain or produce characters that are not
|
||||||
/// visible ASCII (32-127) when serializing to JSON.
|
/// visible ASCII (32-127) when serializing to JSON.
|
||||||
|
@ -118,7 +118,8 @@ pub struct HxResponseTrigger {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HxResponseTrigger {
|
impl HxResponseTrigger {
|
||||||
/// Creates new [trigger](https://htmx.org/headers/hx-trigger/) with specified mode and events.
|
/// Creates new [trigger](https://htmx.org/headers/hx-trigger/) with
|
||||||
|
/// specified mode and events.
|
||||||
pub fn new<T: Into<HxEvent>>(mode: TriggerMode, events: impl IntoIterator<Item = T>) -> Self {
|
pub fn new<T: Into<HxEvent>>(mode: TriggerMode, events: impl IntoIterator<Item = T>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
mode,
|
mode,
|
||||||
|
@ -126,17 +127,20 @@ impl HxResponseTrigger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates new [normal](https://htmx.org/headers/hx-trigger/) trigger from events.
|
/// Creates new [normal](https://htmx.org/headers/hx-trigger/) trigger from
|
||||||
|
/// events.
|
||||||
pub fn normal<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self {
|
pub fn normal<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self {
|
||||||
Self::new(TriggerMode::Normal, events)
|
Self::new(TriggerMode::Normal, events)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates new [after settle](https://htmx.org/headers/hx-trigger/) trigger from events.
|
/// Creates new [after settle](https://htmx.org/headers/hx-trigger/) trigger
|
||||||
|
/// from events.
|
||||||
pub fn after_settle<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self {
|
pub fn after_settle<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self {
|
||||||
Self::new(TriggerMode::AfterSettle, events)
|
Self::new(TriggerMode::AfterSettle, events)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates new [after swap](https://htmx.org/headers/hx-trigger/) trigger from events.
|
/// Creates new [after swap](https://htmx.org/headers/hx-trigger/) trigger
|
||||||
|
/// from events.
|
||||||
pub fn after_swap<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self {
|
pub fn after_swap<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self {
|
||||||
Self::new(TriggerMode::AfterSwap, events)
|
Self::new(TriggerMode::AfterSwap, events)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue