pub struct ComponentArguments {
pub args: Vec<(String, String)>,
pub accepts_text: bool,
}
Expand description
A component can take various arguments (to pass down to its children), which are then later compiled into Rust function arguments - for example
<component name="test" args="a: String, b: bool, c: HashMap<X, Y>">
<Button id="my_button" class="test_{{ a }}"> Is this true? Scientists say: {{ b }}</Button>
</component>
… will turn into the following (generated) Rust code:
ⓘ
struct TestRendererArgs<'a> {
a: &'a String,
b: &'a bool,
c: &'a HashMap<X, Y>,
}
fn render_component_test<'a, T>(args: &TestRendererArgs<'a>) -> StyledDom {
Button::with_label(format!("Is this true? Scientists say: {:?}", args.b)).with_class(format!("test_{}", args.a))
}
For this to work, a component has to note all its arguments and types that it can take.
If a type is not str
or String
, it will be formatted using the {:?}
formatter
in the generated source code, otherwise the compiler will use the {}
formatter.
Fields§
§args: Vec<(String, String)>
The arguments of the component, i.e. date => String
accepts_text: bool
Whether this widget accepts text. Note that this will be passed as the first argument when rendering the Rust code.
Trait Implementations§
Source§impl Clone for ComponentArguments
impl Clone for ComponentArguments
Source§fn clone(&self) -> ComponentArguments
fn clone(&self) -> ComponentArguments
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ComponentArguments
impl Debug for ComponentArguments
Source§impl Default for ComponentArguments
impl Default for ComponentArguments
Source§fn default() -> ComponentArguments
fn default() -> ComponentArguments
Returns the “default value” for a type. Read more
Source§impl Hash for ComponentArguments
impl Hash for ComponentArguments
Source§impl Ord for ComponentArguments
impl Ord for ComponentArguments
Source§fn cmp(&self, other: &ComponentArguments) -> Ordering
fn cmp(&self, other: &ComponentArguments) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ComponentArguments
impl PartialEq for ComponentArguments
Source§impl PartialOrd for ComponentArguments
impl PartialOrd for ComponentArguments
impl Eq for ComponentArguments
impl StructuralPartialEq for ComponentArguments
Auto Trait Implementations§
impl Freeze for ComponentArguments
impl RefUnwindSafe for ComponentArguments
impl Send for ComponentArguments
impl Sync for ComponentArguments
impl Unpin for ComponentArguments
impl UnwindSafe for ComponentArguments
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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