lib.rs 3.5 KB

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