Struct ExecuteScript
pub struct ExecuteScript {
pub script: Cow<'static, str>,
pub auto_remove: Option<bool>,
pub attributes: Option<Vec<ScriptAttribute>>,
}
Expand description
ExecuteScript
executes JavaScript in the browser
See the Datastar documentation.
Fields§
§script: Cow<'static, str>
script
is a string that represents the JavaScript to be executed by the browser.
auto_remove: Option<bool>
Whether to remove the script after execution.
If not provided the Datastar client side will default to true
.
attributes: Option<Vec<ScriptAttribute>>
A list of attributes to add to the script element.
If not provided the Datastar client side will default to type module
.
Each item in the array must be a string in the format key value
,
boolean value used in cased of boolean attributes.
Implementations§
§impl ExecuteScript
impl ExecuteScript
pub const TYPE: EventType = EventType::PatchElements
pub fn new(script: impl Into<Cow<'static, str>>) -> ExecuteScript
pub fn new(script: impl Into<Cow<'static, str>>) -> ExecuteScript
Create a new ExecuteScript
data blob.
pub fn into_sse_event(self) -> Event<ExecuteScript>
pub fn into_sse_event(self) -> Event<ExecuteScript>
Consume self
as an Event
.
pub fn into_datastar_event<T>(self) -> Event<EventData<T>>
pub fn into_datastar_event<T>(self) -> Event<EventData<T>>
Consume self
as a super::DatastarEvent
.
pub fn with_auto_remove(self, auto_remove: bool) -> ExecuteScript
pub fn with_auto_remove(self, auto_remove: bool) -> ExecuteScript
Set whether to remove the script after execution.
pub fn set_auto_remove(&mut self, auto_remove: bool) -> &mut ExecuteScript
pub fn set_auto_remove(&mut self, auto_remove: bool) -> &mut ExecuteScript
Set whether to remove the script after execution.
pub fn with_attribute(self, attribute: ScriptAttribute) -> ExecuteScript
pub fn with_attribute(self, attribute: ScriptAttribute) -> ExecuteScript
Set a single attribute to add to the script element.
This overwrites any previously added script attribute.
pub fn set_attribute(
&mut self,
attribute: ScriptAttribute,
) -> &mut ExecuteScript
pub fn set_attribute( &mut self, attribute: ScriptAttribute, ) -> &mut ExecuteScript
Set a single attribute to add to the script element.
This overwrites any previously added script attribute.
pub fn with_attributes(
self,
attributes: impl IntoIterator<Item = ScriptAttribute>,
) -> ExecuteScript
pub fn with_attributes( self, attributes: impl IntoIterator<Item = ScriptAttribute>, ) -> ExecuteScript
Set a list of attributes to add to the script element.
pub fn set_attributes(
&mut self,
attributes: impl IntoIterator<Item = ScriptAttribute>,
) -> &mut ExecuteScript
pub fn set_attributes( &mut self, attributes: impl IntoIterator<Item = ScriptAttribute>, ) -> &mut ExecuteScript
Set a list of attributes to add to the script element.
pub fn with_additional_attribute(
self,
attribute: ScriptAttribute,
) -> ExecuteScript
pub fn with_additional_attribute( self, attribute: ScriptAttribute, ) -> ExecuteScript
Add an additional attribute
pub fn set_additional_attribute(
&mut self,
attribute: ScriptAttribute,
) -> &mut ExecuteScript
pub fn set_additional_attribute( &mut self, attribute: ScriptAttribute, ) -> &mut ExecuteScript
Add an additional attribute
pub fn with_additional_attributes(
self,
attributes: impl IntoIterator<Item = ScriptAttribute>,
) -> ExecuteScript
pub fn with_additional_attributes( self, attributes: impl IntoIterator<Item = ScriptAttribute>, ) -> ExecuteScript
Set a list of attributes to add to the script element.
pub fn set_additional_attributes(
&mut self,
attributes: impl IntoIterator<Item = ScriptAttribute>,
) -> &mut ExecuteScript
pub fn set_additional_attributes( &mut self, attributes: impl IntoIterator<Item = ScriptAttribute>, ) -> &mut ExecuteScript
Set a list of attributes to add to the script element.
Trait Implementations§
§impl Clone for ExecuteScript
impl Clone for ExecuteScript
§fn clone(&self) -> ExecuteScript
fn clone(&self) -> ExecuteScript
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for ExecuteScript
impl Debug for ExecuteScript
§impl EventDataWrite for ExecuteScript
impl EventDataWrite for ExecuteScript
fn write_data(&self, w: &mut impl Write) -> Result<(), OpaqueError>
§impl<T> From<ExecuteScript> for Event<EventData<T>>
impl<T> From<ExecuteScript> for Event<EventData<T>>
§fn from(value: ExecuteScript) -> Event<EventData<T>>
fn from(value: ExecuteScript) -> Event<EventData<T>>
§impl From<ExecuteScript> for Event<ExecuteScript>
impl From<ExecuteScript> for Event<ExecuteScript>
§fn from(value: ExecuteScript) -> Event<ExecuteScript>
fn from(value: ExecuteScript) -> Event<ExecuteScript>
§impl<T> From<ExecuteScript> for EventData<T>
impl<T> From<ExecuteScript> for EventData<T>
§fn from(value: ExecuteScript) -> EventData<T>
fn from(value: ExecuteScript) -> EventData<T>
§impl Hash for ExecuteScript
impl Hash for ExecuteScript
§impl PartialEq for ExecuteScript
impl PartialEq for ExecuteScript
impl Eq for ExecuteScript
impl StructuralPartialEq for ExecuteScript
Auto Trait Implementations§
impl Freeze for ExecuteScript
impl RefUnwindSafe for ExecuteScript
impl Send for ExecuteScript
impl Sync for ExecuteScript
impl Unpin for ExecuteScript
impl UnwindSafe for ExecuteScript
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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> ⓘ
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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more