mirror of
https://github.com/robertwayne/axum-htmx
synced 2024-12-26 10:19:32 +01:00
Added more from impls for responders
This commit is contained in:
parent
523cbb0371
commit
9c894b8d19
2 changed files with 55 additions and 0 deletions
|
@ -45,6 +45,12 @@ impl IntoResponseParts for HxPushUrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Uri> for HxPushUrl {
|
||||||
|
fn from(uri: Uri) -> Self {
|
||||||
|
Self(uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a str> for HxPushUrl {
|
impl<'a> TryFrom<&'a str> for HxPushUrl {
|
||||||
type Error = <Uri as FromStr>::Err;
|
type Error = <Uri as FromStr>::Err;
|
||||||
|
|
||||||
|
@ -75,6 +81,12 @@ impl IntoResponseParts for HxRedirect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Uri> for HxRedirect {
|
||||||
|
fn from(uri: Uri) -> Self {
|
||||||
|
Self(uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a str> for HxRedirect {
|
impl<'a> TryFrom<&'a str> for HxRedirect {
|
||||||
type Error = <Uri as FromStr>::Err;
|
type Error = <Uri as FromStr>::Err;
|
||||||
|
|
||||||
|
@ -91,6 +103,12 @@ impl<'a> TryFrom<&'a str> for HxRedirect {
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct HxRefresh(pub bool);
|
pub struct HxRefresh(pub bool);
|
||||||
|
|
||||||
|
impl From<bool> for HxRefresh {
|
||||||
|
fn from(value: bool) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IntoResponseParts for HxRefresh {
|
impl IntoResponseParts for HxRefresh {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
|
@ -132,6 +150,12 @@ impl IntoResponseParts for HxReplaceUrl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<Uri> for HxReplaceUrl {
|
||||||
|
fn from(uri: Uri) -> Self {
|
||||||
|
Self(uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> TryFrom<&'a str> for HxReplaceUrl {
|
impl<'a> TryFrom<&'a str> for HxReplaceUrl {
|
||||||
type Error = <Uri as FromStr>::Err;
|
type Error = <Uri as FromStr>::Err;
|
||||||
|
|
||||||
|
@ -158,6 +182,12 @@ impl IntoResponseParts for HxReswap {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<SwapOption> for HxReswap {
|
||||||
|
fn from(value: SwapOption) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The `HX-Retarget` header.
|
/// The `HX-Retarget` header.
|
||||||
///
|
///
|
||||||
/// A CSS selector that updates the target of the content update to a different
|
/// A CSS selector that updates the target of the content update to a different
|
||||||
|
@ -181,6 +211,12 @@ impl IntoResponseParts for HxRetarget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<String> for HxRetarget {
|
||||||
|
fn from(value: String) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// The `HX-Reselect` header.
|
/// The `HX-Reselect` header.
|
||||||
///
|
///
|
||||||
/// A CSS selector that allows you to choose which part of the response is used
|
/// A CSS selector that allows you to choose which part of the response is used
|
||||||
|
@ -204,6 +240,12 @@ impl IntoResponseParts for HxReselect {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<String> for HxReselect {
|
||||||
|
fn from(value: String) -> Self {
|
||||||
|
Self(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Values of the `hx-swap` attribute.
|
/// Values of the `hx-swap` attribute.
|
||||||
// serde::Serialize is implemented in responders/serde.rs
|
// serde::Serialize is implemented in responders/serde.rs
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
|
|
@ -141,6 +141,19 @@ impl HxResponseTrigger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> From<(TriggerMode, T)> for HxResponseTrigger
|
||||||
|
where
|
||||||
|
T: IntoIterator,
|
||||||
|
T::Item: Into<HxEvent>,
|
||||||
|
{
|
||||||
|
fn from((mode, events): (TriggerMode, T)) -> Self {
|
||||||
|
Self {
|
||||||
|
mode,
|
||||||
|
events: events.into_iter().map(Into::into).collect(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IntoResponseParts for HxResponseTrigger {
|
impl IntoResponseParts for HxResponseTrigger {
|
||||||
type Error = HxError;
|
type Error = HxError;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue