Skip to content

Commit

Permalink
Update documentation. #6
Browse files Browse the repository at this point in the history
  • Loading branch information
gudaoxuri committed Mar 9, 2022
1 parent df3b9ce commit bca1a6e
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 7 deletions.
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ categories = [
"database",
"caching",
]
homepage = "https://tardis.idealworld.group"
documentation = "https://tardis.idealworld.group"
homepage = "https://github.com/ideal-world/tardis"
documentation = "https://docs.rs/tardis/"
repository = "https://github.com/ideal-world/tardis"
license = "MIT"
edition = "2021"
Expand Down Expand Up @@ -140,4 +140,8 @@ harness = false
[[bench]]
name = "crypto_benchmark"
harness = false
required-features = ["crypto"]
required-features = ["crypto"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
1 change: 1 addition & 0 deletions src/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::env;

pub mod config;
#[cfg(feature = "crypto")]
#[cfg_attr(docsrs, doc(cfg(feature = "crypto")))]
pub mod crypto;
pub mod dto;
pub mod error;
Expand Down
3 changes: 1 addition & 2 deletions src/basic/field.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::borrow::Cow;
use std::fmt::{Display, Formatter};

use regex::Regex;
Expand Down Expand Up @@ -132,7 +131,7 @@ impl crate::web::poem_openapi::types::Type for TrimString {

type RawElementValueType = Self;

fn name() -> Cow<'static, str> {
fn name() -> std::borrow::Cow<'static, str> {
"trim_string".into()
}

Expand Down
97 changes: 95 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,107 @@
//! **Elegant, Clean Rust development framework🛸**
//!
//! > TARDIS([tɑːrdɪs] "Time And Relative Dimension In Space") From "Doctor Who".
//!
//! ## 💖 Core functions
//!
//! * Relational database client for MySQL, PostgresSQL
//! * Web service and web client for OpenAPI v3.x
//! * Distributed cache client for Redis protocol
//! * RabbitMQ client for AMQP protocol
//! * Mainstream encryption algorithms and SM2/3/4 algorithms
//! * Containerized unit testing of mainstream middleware
//! * Multi-environment configuration
//! * Commonly used operations (E.g. uniform error handling, encryption and decryption, regular
//! checksums)
//!
//! ## ⚙️Feature description
//!
//! * ``trace`` tracing operation
//! * ``crypto`` Encryption, decryption and digest operations
//! * ``future`` asynchronous operations
//! * ``reldb`` relational database operations(based on [SeaORM](https://github.com/SeaQL/sea-orm))
//! * ``web-server`` web service operations(based on [Poem](https://github.com/poem-web/poem))
//! * ``web-client`` web client operations
//! * ``cache`` cache operations
//! * ``mq`` message queue operations
//! * ``test`` unit test operations
//!
//! ## 🚀 Quick start
//!
//! The core operations of the framework all use ``TardisFuns`` as an entry point.
//! E.g.
//!
//!> TardisFuns::init(relative_path) // Initialize the configuration
//!> TardisFuns::field.x // Some field operations
//!> TardisFuns::reldb().x // Some relational database operations
//!> TardisFuns::web_server().x // Some web service operations
//!
//! ### Web service example
//!
//! Dependency Configuration
//! ```toml
//! [dependencies]
//! tardis = { version = "^0", features = ["web-server"] }
//! poem-openapi = { version = "^1"}
//! ```
//!
//! Processor Configuration
//! ```rust
//! pub struct Api;
//!
//! #[OpenApi]
//! impl Api {
//! #[oai(path = "/hello", method = "get")]
//! async fn index(&self, name: Query<Option<String>>) -> TardisResult<String> {
//! match name.0 {
//! Some(name) => TardisResp::ok(format!("hello, {}!", name)),
//! None => TardisResp::err(TardisError::NotFound("name does not exist".to_string())),
//! }
//! }
//! }
//! ```
//!
//! Startup class configuration
//! ```rust
//! #[tokio::main]
//! async fn main() -> TardisResult<()> {
//! // Initial configuration
//! TardisFuns::init::<NoneConfig>("config").await?;
//! // Register the processor and start the web service
//! TardisFuns::web_server().add_module("", Api).start().await
//! }
//! ```
//!
//! ### More examples
//!
//!> |-- examples
//!> |-- reldb Relational database usage example
//!> |-- web-basic Web service Usage Example
//!> |-- web-client Web client Usage Example
//!> |-- webscoket WebSocket Usage Example
//!> |-- cache Cache Usage Example
//!> |-- mq Message Queue Usage Example
//!> |-- todo A complete project usage example
//!> |-- perf-test Performance test case
//!
#![cfg_attr(docsrs, feature(doc_cfg))]

extern crate core;
#[macro_use]
extern crate lazy_static;
extern crate core;

use std::any::Any;
use std::ptr::replace;

pub use chrono;
pub use log;
pub use serde;
pub use serde_json;
#[cfg(feature = "rt_tokio")]
pub use tokio;

use basic::result::TardisResult;
pub use chrono;

use crate::basic::config::{FrameworkConfig, TardisConfig};
use crate::basic::field::TardisField;
Expand Down Expand Up @@ -227,11 +316,15 @@ impl TardisFuns {

pub mod basic;
#[cfg(feature = "cache")]
#[cfg_attr(docsrs, doc(cfg(feature = "cache")))]
pub mod cache;
#[cfg(feature = "reldb")]
#[cfg_attr(docsrs, doc(cfg(feature = "reldb")))]
pub mod db;
#[cfg(feature = "mq")]
#[cfg_attr(docsrs, doc(cfg(feature = "mq")))]
pub mod mq;
#[cfg(feature = "test")]
#[cfg_attr(docsrs, doc(cfg(feature = "test")))]
pub mod test;
pub mod web;
8 changes: 8 additions & 0 deletions src/web.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub use poem;
#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub use poem_openapi;

#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub mod context_extractor;
#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub mod uniform_error_mw;
#[cfg(feature = "web-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-client")))]
pub mod web_client;
#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub mod web_resp;
#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub mod web_server;
#[cfg(feature = "web-server")]
#[cfg_attr(docsrs, doc(cfg(feature = "web-server")))]
pub mod web_validation;

0 comments on commit bca1a6e

Please sign in to comment.