dioxus_core/
lib.rs

1#![doc = include_str!("../README.md")]
2#![doc(html_logo_url = "https://avatars.githubusercontent.com/u/79236386")]
3#![doc(html_favicon_url = "https://avatars.githubusercontent.com/u/79236386")]
4#![warn(missing_docs)]
5
6mod any_props;
7mod arena;
8mod diff;
9mod effect;
10mod error_boundary;
11mod events;
12mod fragment;
13mod generational_box;
14mod global_context;
15mod launch;
16mod mutations;
17mod nodes;
18mod properties;
19mod reactive_context;
20mod render_error;
21mod root_wrapper;
22mod runtime;
23mod scheduler;
24mod scope_arena;
25mod scope_context;
26mod scopes;
27mod suspense;
28mod tasks;
29mod virtual_dom;
30
31mod hotreload_utils;
32
33/// Items exported from this module are used in macros and should not be used directly.
34#[doc(hidden)]
35pub mod internal {
36    pub use crate::properties::verify_component_called_as_component;
37
38    #[doc(hidden)]
39    pub use crate::hotreload_utils::{
40        DynamicLiteralPool, DynamicValuePool, FmtSegment, FmtedSegments, HotReloadAttributeValue,
41        HotReloadDynamicAttribute, HotReloadDynamicNode, HotReloadLiteral,
42        HotReloadTemplateWithLocation, HotReloadedTemplate, HotreloadedLiteral, NamedAttribute,
43        TemplateGlobalKey,
44    };
45
46    #[doc(hidden)]
47    pub use generational_box;
48}
49
50pub(crate) mod innerlude {
51    pub(crate) use crate::any_props::*;
52    pub use crate::arena::*;
53    pub(crate) use crate::effect::*;
54    pub use crate::error_boundary::*;
55    pub use crate::events::*;
56    pub use crate::fragment::*;
57    pub use crate::generational_box::*;
58    pub use crate::global_context::*;
59    pub use crate::launch::*;
60    pub use crate::mutations::*;
61    pub use crate::nodes::*;
62    pub use crate::properties::*;
63    pub use crate::reactive_context::*;
64    pub use crate::render_error::*;
65    pub use crate::runtime::{Runtime, RuntimeGuard};
66    pub use crate::scheduler::*;
67    pub use crate::scopes::*;
68    pub use crate::suspense::*;
69    pub use crate::tasks::*;
70    pub use crate::virtual_dom::*;
71
72    /// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`ScopeId`] or [`ScopeState`].
73    ///
74    /// An Errored [`Element`] will propagate the error to the nearest error boundary.
75    pub type Element = std::result::Result<VNode, RenderError>;
76
77    /// A [`Component`] is a function that takes [`Properties`] and returns an [`Element`].
78    pub type Component<P = ()> = fn(P) -> Element;
79}
80
81pub use crate::innerlude::{
82    fc_to_builder, generation, schedule_update, schedule_update_any, use_hook, vdom_is_rendering,
83    AnyValue, Attribute, AttributeValue, CapturedError, Component, ComponentFunction, DynamicNode,
84    Element, ElementId, Event, Fragment, HasAttributes, IntoDynNode, LaunchConfig, MarkerWrapper,
85    Mutation, Mutations, NoOpMutations, Ok, Properties, Result, Runtime, ScopeId, ScopeState,
86    SpawnIfAsync, Task, Template, TemplateAttribute, TemplateNode, VComponent, VNode, VNodeInner,
87    VPlaceholder, VText, VirtualDom, WriteMutations,
88};
89
90/// The purpose of this module is to alleviate imports of many common types
91///
92/// This includes types like [`Element`], and [`Component`].
93pub mod prelude {
94    pub use crate::innerlude::{
95        consume_context, consume_context_from_scope, current_owner, current_scope_id,
96        fc_to_builder, generation, has_context, needs_update, needs_update_any, parent_scope,
97        provide_context, provide_error_boundary, provide_root_context, queue_effect, remove_future,
98        schedule_update, schedule_update_any, spawn, spawn_forever, spawn_isomorphic, suspend,
99        throw_error, try_consume_context, use_after_render, use_before_render, use_drop, use_hook,
100        use_hook_with_cleanup, with_owner, AnyValue, Attribute, Callback, Component,
101        ComponentFunction, Context, Element, ErrorBoundary, ErrorContext, Event, EventHandler,
102        Fragment, HasAttributes, IntoAttributeValue, IntoDynNode, OptionStringFromMarker,
103        Properties, ReactiveContext, RenderError, Runtime, RuntimeGuard, ScopeId, ScopeState,
104        SuperFrom, SuperInto, SuspendedFuture, SuspenseBoundary, SuspenseBoundaryProps,
105        SuspenseContext, SuspenseExtension, Task, Template, TemplateAttribute, TemplateNode, VNode,
106        VNodeInner, VirtualDom,
107    };
108}
109
110pub use const_format;