diff --git a/src/responders.rs b/src/responders.rs index 1766d12..4352fd7 100644 --- a/src/responders.rs +++ b/src/responders.rs @@ -50,6 +50,8 @@ impl IntoResponseParts for HxLocation { /// /// Will fail if the supplied Uri contains characters that are not visible ASCII /// (32-127). +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxPushUrl(pub Uri); @@ -118,6 +120,8 @@ impl IntoResponseParts for HxRefresh { /// /// Will fail if the supplied Uri contains characters that are not visible ASCII /// (32-127). +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxReplaceUrl(pub Uri); @@ -200,10 +204,14 @@ impl IntoResponseParts for HxReselect { /// The `HX-Trigger` header. /// -/// Allows you to trigger client-side events. +/// Allows you to trigger client-side events. This only accepts events without +/// data attached. If you intend to add data to the event, you must enable the +/// `serde` feature flag. /// /// 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. +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxResponseTrigger(pub Vec); @@ -227,10 +235,14 @@ impl IntoResponseParts for HxResponseTrigger { /// The `HX-Trigger-After-Settle` header. /// -/// Allows you to trigger client-side events after the settle step. +/// Allows you to trigger client-side events after the settle step. This only +/// accepts events without data attached. If you intend to add data to the +/// event, you must enable the `serde` feature flag. /// /// 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. +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxResponseTriggerAfterSettle(pub Vec); @@ -254,10 +266,14 @@ impl IntoResponseParts for HxResponseTriggerAfterSettle { /// The `HX-Trigger-After-Swap` header. /// -/// Allows you to trigger client-side events after the swap step. +/// Allows you to trigger client-side events after the swap step. This only +/// accepts events without data attached. If you intend to add data to the +/// event, you must enable the `serde` feature flag. /// /// 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. +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxResponseTriggerAfterSwap(pub Vec); diff --git a/src/responders/serde.rs b/src/responders/serde.rs index c65aa10..7de1009 100644 --- a/src/responders/serde.rs +++ b/src/responders/serde.rs @@ -88,7 +88,9 @@ impl IntoResponseParts for HxLocation { /// Allows you to trigger client-side events. /// /// 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. +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxTrigger(pub Vec); @@ -108,7 +110,9 @@ impl IntoResponseParts for HxTrigger { /// Allows you to trigger client-side events after the settle step. /// /// 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. +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxTriggerAfterSettle(Vec); @@ -130,7 +134,9 @@ impl IntoResponseParts for HxTriggerAfterSettle { /// Allows you to trigger client-side events after the swap step. /// /// 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. +/// +/// See for more information. #[derive(Debug, Clone)] pub struct HxTriggerAfterSwap(Vec); @@ -157,6 +163,7 @@ impl HxEvent { pub fn new(name: String) -> Self { Self { name, data: None } } + pub fn new_with_data(name: String, data: T) -> Result { let data = serde_json::to_value(data)?;