-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe23eae
commit 6388abd
Showing
5 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//! Traits and structs related to automagically generating documentation for your Rocket routes | ||
|
||
use std::marker::PhantomData; | ||
|
||
#[derive(Default)] | ||
pub struct Docs { | ||
title: Option<String>, | ||
description: Option<String>, | ||
content_type: Option<String>, | ||
} | ||
|
||
pub struct Resolve<T: ?Sized>(PhantomData<T>); | ||
|
||
pub trait Documented { | ||
fn docs() -> Docs; | ||
} | ||
|
||
trait Undocumented { | ||
fn docs() -> Docs { | ||
Docs::default() | ||
} | ||
} | ||
|
||
impl<T: ?Sized> Undocumented for T { } | ||
|
||
impl<T: Documented + ?Sized> Resolve<T> { | ||
pub const DOCUMENTED: bool = true; | ||
|
||
pub fn docs() -> Docs { | ||
T::docs() | ||
} | ||
} | ||
|
||
// impl<T: Documented + ?Sized> Documented for Json<T> { | ||
// fn docs() -> Docs { | ||
// Docs { | ||
// content_type: Some("application/json".to_string()), | ||
// ..Self::docs() | ||
// } | ||
// } | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters