Skip to content

API Reference

ViewWay edited this page Jun 6, 2026 · 1 revision

API Reference / API 参考

Status: 62 Crates, 10 Domains / 62 个 Crate,10 个功能域 状态: 全阶段完成 ✅

Hiver provides comprehensive API documentation across multiple channels. Hiver 通过多个渠道提供全面的 API 文档。


Documentation Resources / 文档资源

Resource / 资源 Link / 链接 Description / 描述
AI-Optimized Reference AGENTS.md Compact LLM-injectable reference (62 crates)
JSON Schema api-schema.json Machine-parseable API catalog
Full API Reference full-api-reference.md Human-readable with code examples
Annotations Reference annotations-reference.md All 150+ procedural macros
Codemap CODEMAP.md Full crate reference, dependency graph
docs.rs docs.rs/hiver Auto-generated rustdoc

Architecture Domains / 架构域

Runtime & Core / 运行时与核心

Crate Description / 描述
hiver-runtime Custom async runtime (io-uring/epoll/kqueue)
hiver-core Core types, error handling
hiver-http HTTP/1.1 server, Request, Response
hiver-router Router with path params, state, middleware
hiver-middleware Middleware trait (CORS, compression, timeout)
hiver-extractors Request parameter extraction
hiver-response Response builders

Data Layer / 数据层

Crate Description / 描述
hiver-data-commons Repository traits, Page/Sort, entity metadata
hiver-data-rdbc Reactive database client, connection pool, RowMapper
hiver-data-orm ActiveRecord, Model derive, QueryBuilder, Relationships, Migrations
hiver-data-redis Redis template, distributed locks, caching
hiver-data-mongodb MongoDB template and repository
hiver-flyway Database migration framework
hiver-data-annotations @Entity, @Table, @Column, @Id
hiver-data-macros #[derive(Model)], #[derive(Repository)]

Resilience & Observability / 弹性与可观测性

Crate Description / 描述
hiver-resilience Circuit breaker, rate limiter, retry, timeout
hiver-observability Distributed tracing, metrics, structured logging

Web3 / 区块链

Crate Description / 描述
hiver-web3 Chain abstraction, wallet, transactions, RPC, smart contracts

IoC & AOP / 控制反转与切面

Crate Description / 描述
hiver-ioc Dependency injection container, @Component, @Autowired
hiver-aop Aspect-oriented programming, @Aspect

Enterprise / 企业级

Crate Description / 描述
hiver-security Authentication, authorization, password encoding
hiver-validation Bean Validation (JSR 380)
hiver-validation-annotations @NotNull, @Size, @Email, @Pattern
hiver-scheduling @Scheduled cron/fixed-rate/delay tasks
hiver-i18n Internationalization, MessageSource

AI & Cloud / AI 与云

Crate Description / 描述
hiver-ai AI/LLM integration, chat models, embeddings
hiver-agent AI agent framework (Spring AI Agent)
hiver-cloud Cloud-native support, service discovery
hiver-ws WebSocket server/client

Tooling & Starter / 工具与启动器

Crate Description / 描述
hiver-macros 150+ procedural macros
hiver-lombok @Data, @Getter, @Setter, @Builder
hiver-retry-macros @Retryable, @Recover
hiver-spel Spring Expression Language engine
hiver-modulith Modular monolith support
hiver-starter Auto-configuration, one-line startup
hiver-test Test utilities, TestClient

Quick API Patterns / 常用 API 模式

Server Startup / 启动服务器

use hiver_http::Server;
use hiver_router::Router;

fn main() -> std::io::Result<()> {
    let mut rt = hiver_runtime::Runtime::new()?;
    rt.block_on(async {
        let app = Router::new()
            .get("/", || async { "Hello, Hiver!" });
        Server::bind("0.0.0.0:8080").run(app).await
    })
}

Using Starter / 使用启动器

use hiver_starter::HiverApp;

fn main() -> std::io::Result<()> {
    HiverApp::new()
        .with_router(Router::new().get("/", handler))
        .run()
}

Data Repository / 数据仓库

use hiver_data_orm::prelude::*;
use hiver_data_annotations::{Entity, Table, Id, Column};

#[derive(Entity, Table, Model)]
#[table_name = "users"]
struct User {
    #[id]
    id: i64,
    #[column]
    name: String,
    email: String,
}

// Auto-generated by #[derive(Repository)]
impl UserRepository {
    async fn find_by_email(&self, email: &str) -> Result<Option<User>> { ... }
    async fn find_by_name_and_email(&self, name: &str, email: &str) -> Result<Vec<User>> { ... }
}

Previous / 上一页 | Next / 下一页

Clone this wiki locally