HxResponseTrigger

Struct HxResponseTrigger 

Source
pub struct HxResponseTrigger {
    pub mode: TriggerMode,
    pub events: Vec<HxEvent>,
}
Expand description

The HX-Trigger* header.

Allows you to trigger client-side events. Corresponds to HX-Trigger, HX-Trigger-After-Settle and HX-Trigger-After-Swap headers. To change when events trigger use appropriate mode.

Will fail if the supplied events contain or produce characters that are not visible ASCII (32-127) when serializing to JSON.

See https://htmx.org/headers/hx-trigger/ for more information.

Note: An HxResponseTrigger implements IntoResponseParts and should be used before any other response object would consume the response parts.

Fields§

§mode: TriggerMode§events: Vec<HxEvent>

Implementations§

Source§

impl HxResponseTrigger

Source

pub fn new<T: Into<HxEvent>>( mode: TriggerMode, events: impl IntoIterator<Item = T>, ) -> Self

Creates new trigger with specified mode and events.

Source

pub fn normal<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self

Creates new normal trigger from events.

See HxResponseTrigger for more information.

Source

pub fn after_settle<T: Into<HxEvent>>( events: impl IntoIterator<Item = T>, ) -> Self

Creates new after settle trigger from events.

See HxResponseTrigger for more information.

Source

pub fn after_swap<T: Into<HxEvent>>(events: impl IntoIterator<Item = T>) -> Self

Creates new after swap trigger from events.

See HxResponseTrigger for more information.

Trait Implementations§

Source§

impl Clone for HxResponseTrigger

Source§

fn clone(&self) -> HxResponseTrigger

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 Debug for HxResponseTrigger

Source§

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

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

impl<T> From<(TriggerMode, T)> for HxResponseTrigger
where T: IntoIterator, T::Item: Into<HxEvent>,

Source§

fn from((mode, events): (TriggerMode, T)) -> Self

Converts to this type from the input type.
Source§

impl IntoResponseParts for HxResponseTrigger

Source§

type Error = HxError

The type returned in the event of an error. Read more
Source§

fn into_response_parts( self, res: ResponseParts, ) -> Result<ResponseParts, Self::Error>

Set parts of the response

Auto Trait Implementations§

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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.