1#![forbid(unsafe_code)]
35
36mod font;
37
38pub use font::LocalFont;
39pub use next_rust_cache::{Cache, CacheEntry, CacheKey, CacheOptions, CacheStore, FileStore, MemoryStore};
40pub use next_rust_core::{Config, Diagnostic, Environment, RenderingMode, config, env as dotenv};
41pub use next_rust_macros::{action, asset, client, css_module, global_css, server, server_action};
42pub use next_rust_router::{ParamValue, Params};
43pub use next_rust_server::*;
44pub use next_rust_view::*;
45
46pub mod deps {
48 pub use next_rust_cache as cache;
49 pub use next_rust_core as core;
50 pub use next_rust_router as router;
51 pub use next_rust_server as server;
52 pub use next_rust_view as view;
53}
54
55pub use next_rust_cache::{cache, invalidate};
57pub use next_rust_server::{revalidate_path, revalidate_tag};
59
60pub mod prelude {
62 pub use next_rust_macros::{action, asset, client, css_module, global_css, server, server_action};
63 pub use next_rust_router::Params;
64 pub use next_rust_server::{
65 ActionContext, Auth, AuthUser, Body, Cookie, Cookies, CsrfToken, Data, Error, ErrorInfo, Extension, FormState,
66 Headers, Html, IntoResponse, Json, Next, Nonce, OrNotFound, Path, Query, Rendering, Request, RequestInfo,
67 Response, ResponseHeaders, Result, Robots, SameSite, Session, Sitemap, SseEvent, not_found, permanent_redirect,
68 redirect,
69 };
70 pub use next_rust_view::metadata::{Icon, OgImage, OpenGraph, Twitter};
71 pub use next_rust_view::*;
72
73 pub use crate::LocalFont;
74}
75
76#[macro_export]
88macro_rules! routes {
89 () => {
90 #[doc(hidden)]
91 #[allow(non_snake_case, clippy::all, clippy::pedantic)]
92 mod __next_rust_routes {
93 include!(concat!(env!("OUT_DIR"), "/next_rust_routes.rs"));
94 }
95 #[allow(unused_imports)]
96 pub use self::__next_rust_routes::routes;
97 };
98}
99
100#[macro_export]
102macro_rules! app {
103 () => {
104 $crate::routes!();
105
106 fn main() {
107 $crate::run(routes());
108 }
109 };
110}
111
112#[doc(hidden)]
113pub mod __private {
114 pub use next_rust_server::__private::*;
115
116 use next_rust_view::{Element, attrs};
117
118 pub fn to_json_value<T: serde::Serialize + ?Sized>(value: &T) -> serde_json::Value {
119 serde_json::to_value(value).unwrap_or(serde_json::Value::Null)
120 }
121
122 pub fn island_props(entries: &[(&str, serde_json::Value)]) -> String {
123 let map: serde_json::Map<String, serde_json::Value> =
124 entries.iter().map(|(k, v)| ((*k).to_owned(), v.clone())).collect();
125 serde_json::Value::Object(map).to_string()
126 }
127
128 pub fn island(component: &str, module: Option<&str>, props: String, view: impl View) -> Node {
129 let mut el =
130 Element::new("nr-island").with(attrs::data("component", component)).with(attrs::data("props", props));
131 if let Some(m) = module {
132 el = el.with(attrs::data("module", m));
133 }
134 el.with(view).into_node()
135 }
136}