vidi_smol/
lib.rs

1//! Vidi
2//!
3//! Fast, robust, flexible, lightweight web framework for Rust.
4//!
5//! # Features
6//!
7//! * **Safety** `#![forbid(unsafe_code)]`
8//!
9//! * Lightweight
10//!
11//! * Simple + Flexible [`Handler`](#handler) & [`Middleware`](#middleware)
12//!
13//! * Handy [`Extractors`](#extractors)
14//!
15//! * Robust [`Routing`](#routing)
16//!
17//! * Supports Tower [`Service`]
18//!
19//! # Hello Vidi
20//!
21//! ```no_run
22//! use std::io;
23//! use std::sync::Arc;
24//!
25//! use async_net::TcpListener;
26//! use macro_rules_attribute::apply;
27//! use smol_macros::{Executor, main};
28//! use vidi_smol::{Request, Result, Router};
29//!
30//! async fn index(_: Request) -> Result<&'static str> {
31//!     Ok("Hello, Vidi!")
32//! }
33//!
34//! #[apply(main!)]
35//! async fn main(ex: &Arc<Executor<'_>>) -> io::Result<()> {
36//!     // Build our application with a route.
37//!     let app = Router::new().get("/", index);
38//!
39//!     // Create a `smol`-based TCP listener.
40//!     let listener = TcpListener::bind(("127.0.0.1", 3000)).await.unwrap();
41//!     println!("listening on {}", listener.local_addr().unwrap());
42//!
43//!     // Run it
44//!     vidi_smol::serve(ex, listener, app).await
45//! }
46//! ```
47//!
48//! [`Service`]: https://docs.rs/tower-service/latest/tower_service/trait.Service.html
49
50#![doc(html_logo_url = "https://viz.rs/logo.svg")]
51#![doc(html_favicon_url = "https://viz.rs/logo.svg")]
52#![doc(test(
53    no_crate_inject,
54    attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
55))]
56#![cfg_attr(docsrs, feature(doc_cfg))]
57
58mod responder;
59pub use responder::Responder;
60
61mod listener;
62pub use listener::Listener;
63
64mod server;
65pub use server::serve;
66
67// #[cfg(any(feature = "native-tls", feature = "rustls"))]
68// pub use server::tls;
69
70pub use vidi_core::*;
71pub use vidi_router::*;
72
73#[cfg(feature = "handlers")]
74#[cfg_attr(docsrs, doc(cfg(feature = "handlers")))]
75#[doc(inline)]
76pub use vidi_handlers as handlers;
77
78#[cfg(feature = "macros")]
79#[cfg_attr(docsrs, doc(cfg(feature = "macros")))]
80#[doc(inline)]
81pub use vidi_macros::handler;