lib.rs 2.8 KB

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