Skip to content

Commit

Permalink
update documentation on gotham_derive crate (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
msrd0 committed Nov 6, 2021
1 parent ecc604d commit 8ce37b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
10 changes: 3 additions & 7 deletions gotham/src/state/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,12 @@ pub use gotham_derive::StateData;

/// A marker trait for types that can be stored in `State`.
///
/// This is typically implemented using `#[derive(StateData)]`, which is provided by the
/// `gotham_derive` crate.
/// This is typically implemented using `#[derive(StateData)]`.
///
/// ```rust
/// # extern crate gotham;
/// # #[macro_use]
/// # extern crate gotham_derive;
/// #
/// # use gotham::state::{FromState, State};
/// #
/// use gotham::state::StateData;
///
/// #[derive(StateData)]
/// struct MyStateData {
/// x: u32,
Expand Down
11 changes: 3 additions & 8 deletions gotham/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,18 @@ impl Hasher for IdHasher {
}

/// Provides storage for request state, and stores one item of each type. The types used for
/// storage must implement the `gotham::state::StateData` trait to allow its storage. The
/// `gotham_derive` crate provides a custom derive for `StateData` to make this more convenient.
/// storage must implement the [`StateData`] trait to allow its storage, which is usually done
/// by adding `#[derive(StateData)]` on the type in question.
///
/// # Examples
///
/// ```rust
/// extern crate gotham;
/// #[macro_use]
/// extern crate gotham_derive;
///
/// use gotham::state::State;
/// use gotham::state::{State, StateData};
///
/// #[derive(StateData)]
/// struct MyStruct {
/// value: i32,
/// }
///
/// # fn main() {
/// # State::with_new(|state| {
/// #
Expand Down
3 changes: 3 additions & 0 deletions gotham_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//! This crate is a private implementation detail of `gotham`. You should never have to
//! use this crate directly.

mod extenders;
mod new_middleware;
mod state;
Expand Down
4 changes: 0 additions & 4 deletions middleware/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
#[macro_use]
extern crate log;

// Enable to use #[derive(StateData)] below
//#[macro_use]
//extern crate gotham_derive;

use std::pin::Pin;

use futures_util::future::{self, FutureExt, TryFutureExt};
Expand Down

0 comments on commit 8ce37b0

Please sign in to comment.