diff --git a/src/color.rs b/src/color.rs index a7988cf..4a5b0a4 100644 --- a/src/color.rs +++ b/src/color.rs @@ -1,7 +1,15 @@ +//! Cheesy way to easily wrap text in console colors. +//! Example: +//! ``` +//! use phd::color; +//! println!("{}Error: {}{}", color::Red, "Something broke.", color::Reset); +//! ``` + use std::fmt; macro_rules! color { ($t:ident, $code:expr) => { + #[allow(missing_docs)] pub struct $t; impl fmt::Display for $t { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { diff --git a/src/lib.rs b/src/lib.rs index 5be46c1..908cbca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,20 @@ +//! phd is a small, easy-to-use Gopher server that tries to make +//! serving up a Gopher site quick and painless. Best used for local +//! development or low traffic Gopher sites. + +#![allow(unused_must_use)] +#![warn(absolute_paths_not_starting_with_crate)] +#![warn(explicit_outlives_requirements)] +#![warn(unreachable_pub)] +#![warn(deprecated_in_future)] +#![warn(missing_docs)] +#![allow(clippy::while_let_on_iterator)] + pub mod color; pub mod request; pub mod server; pub use crate::request::Request; +/// Alias for a generic Result type. pub type Result = std::result::Result>; diff --git a/src/request.rs b/src/request.rs index 461fbd0..5052ff0 100644 --- a/src/request.rs +++ b/src/request.rs @@ -1,13 +1,23 @@ +//! A Request represents a Gopher request made by a client. phd can +//! serve directory listings as Gopher Menus, plain text files as +//! Text, binary files as downloads, Gophermap files as menus, or +//! executable files as dynamic content. + use crate::Result; use std::fs; /// This struct represents a single gopher request. #[derive(Debug, Clone)] pub struct Request { + /// Gopher selector requested pub selector: String, + /// Search query string, if any. pub query: String, + /// Root directory of the server. Can't serve outside of this. pub root: String, + /// Host of the currently running server. pub host: String, + /// Port of the currently running server. pub port: u16, } diff --git a/src/server.rs b/src/server.rs index 2e8d782..d485822 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,3 +1,5 @@ +//! A simple multi-threaded Gopher server. + use crate::{color, Request, Result}; use gophermap::{GopherMenu, ItemType}; use std::{