lib.rs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #![doc = include_str!("../README.md")]
  2. #![warn(missing_docs)]
  3. mod any_props;
  4. mod arena;
  5. mod bump_frame;
  6. mod create;
  7. mod diff;
  8. mod dirty_scope;
  9. mod error_boundary;
  10. mod events;
  11. mod fragment;
  12. mod lazynodes;
  13. mod mutations;
  14. mod nodes;
  15. mod properties;
  16. mod runtime;
  17. mod scheduler;
  18. mod scope_arena;
  19. mod scope_context;
  20. mod scopes;
  21. mod virtual_dom;
  22. pub(crate) mod innerlude {
  23. pub use crate::arena::*;
  24. pub use crate::dirty_scope::*;
  25. pub use crate::error_boundary::*;
  26. pub use crate::events::*;
  27. pub use crate::fragment::*;
  28. pub use crate::lazynodes::*;
  29. pub use crate::mutations::*;
  30. pub use crate::nodes::RenderReturn;
  31. pub use crate::nodes::*;
  32. pub use crate::properties::*;
  33. pub use crate::runtime::{Runtime, RuntimeGuard};
  34. pub use crate::scheduler::*;
  35. pub use crate::scope_context::*;
  36. pub use crate::scopes::*;
  37. pub use crate::virtual_dom::*;
  38. /// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`Scope`] or [`ScopeState`].
  39. ///
  40. /// An Errored [`Element`] will propagate the error to the nearest error boundary.
  41. pub type Element<'a> = Option<VNode<'a>>;
  42. /// A [`Component`] is a function that takes a [`Scope`] and returns an [`Element`].
  43. ///
  44. /// Components can be used in other components with two syntax options:
  45. /// - lowercase as a function call with named arguments (rust style)
  46. /// - uppercase as an element (react style)
  47. ///
  48. /// ## Rust-Style
  49. ///
  50. /// ```rust, ignore
  51. /// fn example(cx: Scope<Props>) -> Element {
  52. /// // ...
  53. /// }
  54. ///
  55. /// rsx!(
  56. /// example()
  57. /// )
  58. /// ```
  59. /// ## React-Style
  60. /// ```rust, ignore
  61. /// fn Example(cx: Scope<Props>) -> Element {
  62. /// // ...
  63. /// }
  64. ///
  65. /// rsx!(
  66. /// Example {}
  67. /// )
  68. /// ```
  69. pub type Component<P = ()> = fn(Scope<P>) -> Element;
  70. }
  71. pub use crate::innerlude::{
  72. fc_to_builder, vdom_is_rendering, AnyValue, Attribute, AttributeValue, BorrowedAttributeValue,
  73. CapturedError, Component, DynamicNode, Element, ElementId, Event, Fragment, IntoDynNode,
  74. LazyNodes, Mutation, Mutations, Properties, RenderReturn, Scope, ScopeId, ScopeState, Scoped,
  75. TaskId, Template, TemplateAttribute, TemplateNode, VComponent, VNode, VPlaceholder, VText,
  76. VirtualDom,
  77. };
  78. /// The purpose of this module is to alleviate imports of many common types
  79. ///
  80. /// This includes types like [`Scope`], [`Element`], and [`Component`].
  81. pub mod prelude {
  82. pub use crate::innerlude::{
  83. consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, has_context,
  84. provide_context, provide_context_to_scope, provide_root_context, push_future,
  85. remove_future, schedule_update_any, spawn, spawn_forever, suspend, throw, AnyValue,
  86. Component, Element, Event, EventHandler, Fragment, IntoAttributeValue, LazyNodes,
  87. Properties, Runtime, RuntimeGuard, Scope, ScopeId, ScopeState, Scoped, TaskId, Template,
  88. TemplateAttribute, TemplateNode, Throw, VNode, VirtualDom,
  89. };
  90. }
  91. pub mod exports {
  92. //! Important dependencies that are used by the rest of the library
  93. //! Feel free to just add the dependencies in your own Crates.toml
  94. pub use bumpalo;
  95. }