lib.rs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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::scheduler::*;
  34. pub use crate::scope_context::*;
  35. pub use crate::scopes::*;
  36. pub use crate::virtual_dom::*;
  37. /// An [`Element`] is a possibly-none [`VNode`] created by calling `render` on [`Scope`] or [`ScopeState`].
  38. ///
  39. /// An Errored [`Element`] will propagate the error to the nearest error boundary.
  40. pub type Element<'a> = Option<VNode<'a>>;
  41. /// A [`Component`] is a function that takes a [`Scope`] and returns an [`Element`].
  42. ///
  43. /// Components can be used in other components with two syntax options:
  44. /// - lowercase as a function call with named arguments (rust style)
  45. /// - uppercase as an element (react style)
  46. ///
  47. /// ## Rust-Style
  48. ///
  49. /// ```rust, ignore
  50. /// fn example(cx: Scope<Props>) -> Element {
  51. /// // ...
  52. /// }
  53. ///
  54. /// rsx!(
  55. /// example()
  56. /// )
  57. /// ```
  58. /// ## React-Style
  59. /// ```rust, ignore
  60. /// fn Example(cx: Scope<Props>) -> Element {
  61. /// // ...
  62. /// }
  63. ///
  64. /// rsx!(
  65. /// Example {}
  66. /// )
  67. /// ```
  68. pub type Component<P = ()> = fn(Scope<P>) -> Element;
  69. }
  70. pub use crate::innerlude::{
  71. fc_to_builder, vdom_is_rendering, AnyValue, Attribute, AttributeValue, BorrowedAttributeValue,
  72. CapturedError, Component, DynamicNode, Element, ElementId, Event, Fragment, IntoDynNode,
  73. LazyNodes, Mutation, Mutations, Properties, RenderReturn, Scope, ScopeId, ScopeState, Scoped,
  74. TaskId, Template, TemplateAttribute, TemplateNode, VComponent, VNode, VPlaceholder, VText,
  75. VirtualDom,
  76. };
  77. /// The purpose of this module is to alleviate imports of many common types
  78. ///
  79. /// This includes types like [`Scope`], [`Element`], and [`Component`].
  80. pub mod prelude {
  81. pub use crate::innerlude::{
  82. consume_context, consume_context_from_scope, current_scope_id, fc_to_builder, has_context,
  83. provide_context, provide_context_to_scope, provide_root_context, push_future,
  84. remove_future, schedule_update_any, spawn, spawn_forever, suspend, throw, AnyValue,
  85. Component, Element, Event, EventHandler, Fragment, IntoAttributeValue, LazyNodes,
  86. Properties, Scope, ScopeId, ScopeState, Scoped, TaskId, Template, TemplateAttribute,
  87. TemplateNode, Throw, VNode, VirtualDom,
  88. };
  89. }
  90. pub mod exports {
  91. //! Important dependencies that are used by the rest of the library
  92. //! Feel free to just add the dependencies in your own Crates.toml
  93. pub use bumpalo;
  94. }