Crate this

Crate this 

Source
Expand description

§This-RS Framework

A generic entity and relationship management framework for building RESTful APIs in Rust.

§Features

  • Entity/Data/Link Architecture: Clean hierarchy with macro-based implementation
  • Flexible Relationships: Support multiple link types between entities
  • Bidirectional Navigation: Query relationships from both directions
  • Auto-Pluralization: Intelligent plural forms (company → companies)
  • Configuration-Based: Define relationships via YAML configuration
  • Type-Safe: Leverage Rust’s type system for compile-time guarantees
  • Soft Delete Support: Built-in soft deletion with deleted_at
  • Automatic Timestamps: created_at and updated_at managed automatically

§Quick Start

use this::prelude::*;

// Define a Data entity (extends Entity base)
impl_data_entity!(
    User,
    "user",
    ["name", "email"],
    {
        email: String,
        password_hash: String,
    }
);

// Define a Link entity (extends Entity base)
impl_link_entity!(
    UserCompanyLink,
    "user_company_link",
    {
        role: String,
        start_date: DateTime<Utc>,
    }
);

// Usage
let user = User::new(
    "John Doe".to_string(),
    "active".to_string(),
    "john@example.com".to_string(),
    "$argon2$...".to_string(),
);

user.soft_delete(); // Soft delete support
user.restore();     // Restore support

Modules§

config
Configuration loading and management
core
Core module containing fundamental traits and types for the framework
entities
Entity-specific code and macros
links
Link management module
prelude
Re-exports of commonly used types and traits
server
Server module for building HTTP servers with auto-registered routes
storage
Storage implementations for different backends

Macros§

add_filters_for_field
Helper macro to add filters to a field
add_validators_for_field
Helper macro to add validators to a field
data_fields
Macro to inject Data fields into a struct (Entity fields + name)
entity_fields
Macro to inject Entity base fields into a struct
impl_data_entity
Complete macro to create a Data entity with automatic trait implementations
impl_data_entity_validated
Extended macro to create a Data entity with validation and filtering
impl_entity_multi_tenant
Helper macro to enable multi-tenancy for an entity
impl_link_entity
Complete macro to create a Link entity with automatic trait implementations
link_fields
Macro to inject Link fields into a struct (Entity fields + source_id + target_id + link_type)