pub struct ExecuteScript {
pub script: NonEmptyStr,
pub auto_remove: Option<bool>,
pub attributes: Option<Vec<ScriptAttribute>>,
}Expand description
ExecuteScript executes JavaScript in the browser
See the Datastar documentation.
Fields§
§script: NonEmptyStrscript 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§
Source§impl ExecuteScript
impl ExecuteScript
pub const TYPE: EventType = EventType::PatchElements
Sourcepub const fn new(script: NonEmptyStr) -> ExecuteScript
pub const fn new(script: NonEmptyStr) -> ExecuteScript
Create a new ExecuteScript data blob.
Sourcepub fn try_into_sse_event(self) -> Result<Event<ExecuteScript>, EventBuildError>
pub fn try_into_sse_event(self) -> Result<Event<ExecuteScript>, EventBuildError>
Consume self as an Event.
Sourcepub fn try_into_datastar_event<T>(
self,
) -> Result<Event<EventData<T>>, EventBuildError>
pub fn try_into_datastar_event<T>( self, ) -> Result<Event<EventData<T>>, EventBuildError>
Consume self as a super::DatastarEvent.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub fn with_additional_attribute(
self,
attribute: ScriptAttribute,
) -> ExecuteScript
pub fn with_additional_attribute( self, attribute: ScriptAttribute, ) -> ExecuteScript
Add an additional attribute
Sourcepub 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
Sourcepub 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.
Sourcepub 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§
Source§impl Clone for ExecuteScript
impl Clone for ExecuteScript
Source§fn clone(&self) -> ExecuteScript
fn clone(&self) -> ExecuteScript
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecuteScript
impl Debug for ExecuteScript
impl Eq for ExecuteScript
Source§impl EventDataWrite for ExecuteScript
impl EventDataWrite for ExecuteScript
Source§impl<T> From<ExecuteScript> for EventData<T>
impl<T> From<ExecuteScript> for EventData<T>
Source§fn from(value: ExecuteScript) -> EventData<T>
fn from(value: ExecuteScript) -> EventData<T>
Source§impl Hash for ExecuteScript
impl Hash for ExecuteScript
Source§impl PartialEq for ExecuteScript
impl PartialEq for ExecuteScript
Source§fn eq(&self, other: &ExecuteScript) -> bool
fn eq(&self, other: &ExecuteScript) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ExecuteScript
Source§impl TryFrom<ExecuteScript> for Event<ExecuteScript>
impl TryFrom<ExecuteScript> for Event<ExecuteScript>
Source§type Error = EventBuildError
type Error = EventBuildError
Source§fn try_from(
value: ExecuteScript,
) -> Result<Event<ExecuteScript>, <Event<ExecuteScript> as TryFrom<ExecuteScript>>::Error>
fn try_from( value: ExecuteScript, ) -> Result<Event<ExecuteScript>, <Event<ExecuteScript> as TryFrom<ExecuteScript>>::Error>
Auto Trait Implementations§
impl Freeze for ExecuteScript
impl RefUnwindSafe for ExecuteScript
impl Send for ExecuteScript
impl Sync for ExecuteScript
impl Unpin for ExecuteScript
impl UnsafeUnpin for ExecuteScript
impl UnwindSafe for ExecuteScript
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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