diff options
| author | Fuwn <[email protected]> | 2022-03-27 07:00:44 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-03-27 07:00:44 +0000 |
| commit | b9d9031dc938900a96ae0e27df16931b21083a1f (patch) | |
| tree | d5c13fa5595d2efe1cd9a724ddf13a116bc91d0c | |
| parent | docs(readme): fix example (diff) | |
| download | windmark-b9d9031dc938900a96ae0e27df16931b21083a1f.tar.xz windmark-b9d9031dc938900a96ae0e27df16931b21083a1f.zip | |
docs: extend
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | Makefile.toml | 6 | ||||
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | src/lib.rs | 55 | ||||
| -rw-r--r-- | src/response.rs | 3 | ||||
| -rw-r--r-- | src/utilities.rs | 3 |
6 files changed, 76 insertions, 7 deletions
@@ -2,7 +2,7 @@ [package] name = "windmark" -version = "0.1.1" +version = "0.1.2" authors = ["Fuwn <[email protected]>"] edition = "2021" description = "An elegant and highly performant async Gemini server framework" diff --git a/Makefile.toml b/Makefile.toml index d6b203e..9ae10e6 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -57,3 +57,9 @@ args = [ "-out", "windmark_pair.pem" ] + +[tasks.docs] +workspace = false +toolchain = "nightly" +command = "cargo" +args = ["doc", "--open", "--no-deps"] @@ -4,7 +4,7 @@ [](https://docs.rs/windmark) [](https://github.com/gemrest/windmark/actions/workflows/check.yaml) -Windmark is An elegant and highly performant async Gemini server framework. +Windmark is an elegant and highly performant, async Gemini server framework. ## Usage @@ -14,10 +14,10 @@ Windmark is An elegant and highly performant async Gemini server framework. # Cargo.toml [dependencies] -windmark = "0.1.1" +windmark = "0.1.2" -# If you would like to use the built-in logger (reccomended) -# windmark = { version = "0.1.1", features = ["logger"] } +# If you would like to use the built-in logger (recommended) +# windmark = { version = "0.1.2", features = ["logger"] } ``` ### Implement a Windmark server @@ -43,8 +43,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { ## Examples -Examples can be found within the [`examples/`](./examples) directory. +Examples can be found within the +[`examples/`](https://github.com/gemrest/windmark/tree/main/examples) directory. ## License -This project is licensed with the [GNU General Public License v3.0](./LICENSE). +This project is licensed with the +[GNU General Public License v3.0](https://github.com/gemrest/windmark/blob/main/LICENSE). @@ -16,6 +16,59 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +//! # Windmark +//! +//! [](https://crates.io/crates/windmark) +//! [](https://docs.rs/windmark) +//! [](https://github.com/gemrest/windmark/actions/workflows/check.yaml) +//! +//! Windmark is an elegant and highly performant, async Gemini server framework. +//! +//! ## Usage +//! +//! ### Add Windmark as a dependency +//! +//! ```toml +//! # Cargo.toml +//! +//! [dependencies] +//! windmark = "0.1.2" +//! +//! # If you would like to use the built-in logger (recommended) +//! # windmark = { version = "0.1.2", features = ["logger"] } +//! ``` +//! +//! ### Implement a Windmark server +//! +//! ```rust +//! // src/main.rs +//! +//! use windmark::Response; +//! +//! #[windmark::main] +//! fn main() -> Result<(), Box<dyn std::error::Error>> { +//! windmark::Router::new() +//! .set_private_key_file("windmark_private.pem") +//! .set_certificate_chain_file("windmark_pair.pem") +//! .mount("/", |_| Response::Success("Hello, World!".into())) +//! .set_error_handler(|_| { +//! Response::PermanentFailure("This route does not exist!".into()) +//! }) +//! .run() +//! .await +//! } +//! ``` +//! +//! ## Examples +//! +//! Examples can be found within the +//! [`examples/`](https://github.com/gemrest/windmark/tree/main/examples) directory. +//! +//! ## License +//! +//! This project is licensed with the +//! [GNU General Public License v3.0](https://github.com/gemrest/windmark/blob/main/LICENSE). + #![feature(once_cell)] #![deny( warnings, @@ -53,6 +106,8 @@ use crate::{ returnable::{ErrorContext, RouteContext}, }; +/// A router which takes care of all tasks a Windmark server should handle: +/// response generation, panics, logging, and more. #[derive(Clone)] pub struct Router { routes: matchit::Router<RouteResponse>, diff --git a/src/response.rs b/src/response.rs index d89dbf2..b9c5354 100644 --- a/src/response.rs +++ b/src/response.rs @@ -16,6 +16,9 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +//! Content and response handlers + +/// The content and response type a handler should reply with. pub enum Response<'a> { Input(String), SensitiveInput(String), diff --git a/src/utilities.rs b/src/utilities.rs index 0d34dba..68962ff 100644 --- a/src/utilities.rs +++ b/src/utilities.rs @@ -16,8 +16,11 @@ // Copyright (C) 2022-2022 Fuwn <[email protected]> // SPDX-License-Identifier: GPL-3.0-only +//! Utilities to make cumbersome tasks simpler + use std::collections::HashMap; +/// Extract the queries from a URL into a `HashMap`. #[must_use] pub fn queries_from_url(url: &url::Url) -> HashMap<String, String> { let mut queries = HashMap::new(); |