aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-03-27 07:00:44 +0000
committerFuwn <[email protected]>2022-03-27 07:00:44 +0000
commitb9d9031dc938900a96ae0e27df16931b21083a1f (patch)
treed5c13fa5595d2efe1cd9a724ddf13a116bc91d0c
parentdocs(readme): fix example (diff)
downloadwindmark-b9d9031dc938900a96ae0e27df16931b21083a1f.tar.xz
windmark-b9d9031dc938900a96ae0e27df16931b21083a1f.zip
docs: extend
-rw-r--r--Cargo.toml2
-rw-r--r--Makefile.toml6
-rw-r--r--README.md14
-rw-r--r--src/lib.rs55
-rw-r--r--src/response.rs3
-rw-r--r--src/utilities.rs3
6 files changed, 76 insertions, 7 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 26a0195..8347114 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"]
diff --git a/README.md b/README.md
index bc5b44c..9d6be5c 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
[![docs.rs](https://docs.rs/windmark/badge.svg)](https://docs.rs/windmark)
[![github.com](https://github.com/gemrest/windmark/actions/workflows/check.yaml/badge.svg?branch=main)](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).
diff --git a/src/lib.rs b/src/lib.rs
index 1563c62..0c6ebf7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -16,6 +16,59 @@
// Copyright (C) 2022-2022 Fuwn <[email protected]>
// SPDX-License-Identifier: GPL-3.0-only
+//! # Windmark
+//!
+//! [![crates.io](https://img.shields.io/crates/v/windmark.svg)](https://crates.io/crates/windmark)
+//! [![docs.rs](https://docs.rs/windmark/badge.svg)](https://docs.rs/windmark)
+//! [![github.com](https://github.com/gemrest/windmark/actions/workflows/check.yaml/badge.svg?branch=main)](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();