pub struct View<G>where
G: GenericNode,{ /* private fields */ }
Expand description
Represents an UI view. Usually constructed using the view!
macro or using the builder API.
§Example
let my_view: View<G> = view! {
div {
p { "A view." }
}
};
Implementations§
§impl<G> View<G>where
G: GenericNode,
impl<G> View<G>where
G: GenericNode,
pub fn new_fragment(fragment: Vec<View<G>>) -> View<G>
pub fn new_fragment(fragment: Vec<View<G>>) -> View<G>
pub fn empty() -> View<G>
pub fn empty() -> View<G>
Create a new View
with a blank marker node
Note that this is different from an empty view fragment. Instead, this is a single marker (dummy) node.
pub fn as_node(&self) -> Option<&G>
pub fn as_node(&self) -> Option<&G>
Try to cast to a GenericNode
, or None
if wrong type.
pub fn as_fragment(&self) -> Option<&[View<G>]>
pub fn as_fragment(&self) -> Option<&[View<G>]>
Try to cast to a slice representing the view fragment, or None
if wrong type.
pub fn as_dyn(&self) -> Option<ReadSignal<View<G>>>
pub fn as_dyn(&self) -> Option<ReadSignal<View<G>>>
Try to cast to the underlying [RcSignal
] for a dynamic view, or None
if wrong type.
pub fn is_node(&self) -> bool
pub fn is_node(&self) -> bool
Returns true
if the view is a single node. Note that if the view is a fragment containing
only a single child node, this will still return false
.
To check whether the View
only contains a single node, use .flatten().len() == 1
instead.
pub fn is_fragment(&self) -> bool
pub fn is_fragment(&self) -> bool
Returns true
if the view is a view fragment.
Trait Implementations§
§impl<G> Clone for View<G>where
G: Clone + GenericNode,
impl<G> Clone for View<G>where
G: Clone + GenericNode,
§impl<G> Debug for View<G>where
G: GenericNode,
impl<G> Debug for View<G>where
G: GenericNode,
§impl<G> Default for View<G>where
G: GenericNode,
impl<G> Default for View<G>where
G: GenericNode,
source§impl<G: GenericNode> ElementBuilderOrView<G> for View<G>
impl<G: GenericNode> ElementBuilderOrView<G> for View<G>
§impl<G> From<View<G>> for Children<G>where
G: GenericNode,
impl<G> From<View<G>> for Children<G>where
G: GenericNode,
Auto Trait Implementations§
impl<G> Freeze for View<G>
impl<G> !RefUnwindSafe for View<G>
impl<G> !Send for View<G>
impl<G> !Sync for View<G>
impl<G> Unpin for View<G>
impl<G> !UnwindSafe for View<G>
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