Type Alias StringAttribute

pub type StringAttribute = MaybeDyn<Option<Cow<'static, str>>>;
Expand description

Type alias representing a possibly dynamic string value.

Aliased Type§

enum StringAttribute {
    Static(Option<Cow<'static, str>>),
    Signal(ReadSignal<Option<Cow<'static, str>>>),
    Derived(Rc<dyn Fn() -> MaybeDyn<Option<Cow<'static, str>>>>),
}

Variants§

§

Static(Option<Cow<'static, str>>)

A static value.

§

Signal(ReadSignal<Option<Cow<'static, str>>>)

A dynamic value backed by a signal.

§

Derived(Rc<dyn Fn() -> MaybeDyn<Option<Cow<'static, str>>>>)

A derived dynamic value.

Implementations

§

impl<T> MaybeDyn<T>
where T: Into<MaybeDyn<T>> + 'static,

pub fn evaluate(self) -> T
where T: Clone,

Get the value by consuming itself. Unlike get_clone, this method avoids a clone if we are just storing a static value.

pub fn get(&self) -> T
where T: Copy,

Get the value by copying it.

If the type does not implement Copy, consider using get_clone instead.

pub fn get_clone(&self) -> T
where T: Clone,

Get the value by cloning it.

If the type implements Copy, consider using get instead.

pub fn track(&self)

Track the reactive dependencies, if it is dynamic.

pub fn as_static(&self) -> Option<&T>

Tries to get the value statically or returns None if value is dynamic.

Trait Implementations

§

impl AttributeValue for MaybeDyn<Option<Cow<'static, str>>>

§

fn set_self(self, el: &mut SsrNode, name: Cow<'static, str>)

§

impl<T> Clone for MaybeDyn<T>
where T: Clone + Into<MaybeDyn<T>> + 'static,

§

fn clone(&self) -> MaybeDyn<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl From<&'static str> for MaybeDyn<Option<Cow<'static, str>>>

§

fn from(val: &'static str) -> MaybeDyn<Option<Cow<'static, str>>>

Converts to this type from the input type.
§

impl From<Cow<'static, str>> for MaybeDyn<Option<Cow<'static, str>>>

§

fn from(val: Cow<'static, str>) -> MaybeDyn<Option<Cow<'static, str>>>

Converts to this type from the input type.
§

impl<F, U, T> From<F> for MaybeDyn<T>
where T: Into<MaybeDyn<T>>, F: Fn() -> U + 'static, U: Into<MaybeDyn<T>>,

§

fn from(f: F) -> MaybeDyn<T>

Converts to this type from the input type.
§

impl From<Option<&'static str>> for MaybeDyn<Option<Cow<'static, str>>>

§

fn from(val: Option<&'static str>) -> MaybeDyn<Option<Cow<'static, str>>>

Converts to this type from the input type.
§

impl From<Option<String>> for MaybeDyn<Option<Cow<'static, str>>>

§

fn from(val: Option<String>) -> MaybeDyn<Option<Cow<'static, str>>>

Converts to this type from the input type.
§

impl<T> From<Option<T>> for MaybeDyn<Option<T>>

§

fn from(val: Option<T>) -> MaybeDyn<Option<T>>

Converts to this type from the input type.
§

impl<T, U> From<ReadSignal<U>> for MaybeDyn<T>
where T: Into<MaybeDyn<T>>, U: Into<MaybeDyn<T>> + Clone,

§

fn from(val: ReadSignal<U>) -> MaybeDyn<T>

Converts to this type from the input type.
§

impl<T, U> From<Signal<U>> for MaybeDyn<T>
where T: Into<MaybeDyn<T>>, U: Into<MaybeDyn<T>> + Clone,

§

fn from(val: Signal<U>) -> MaybeDyn<T>

Converts to this type from the input type.
§

impl From<String> for MaybeDyn<Option<Cow<'static, str>>>

§

fn from(val: String) -> MaybeDyn<Option<Cow<'static, str>>>

Converts to this type from the input type.