dto-domain

Enforce Row, Dto, and Domain type separation in Rust data models.

Updated May 26, 2026
One-click install
npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill dto-domain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dto-domain
Source: https://github.com/adelabdelgawad/rust-fullstack-agents/tree/main/plugins/rusty/skills/dto-domain
Command: npx skills add https://github.com/adelabdelgawad/rust-fullstack-agents --skill dto-domain

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Three-layer architecture discipline for Rust projects to clearly separate DB rows (Row), wire DTOs (Dto), and domain invariants, preventing leakage of internal state and ensuring consistent conversions.

Core Features & Use Cases

  • Enforces a three-layer pattern (Row, Dto, Domain) per entity with explicit boundaries.
  • Provides conversion direction: Row → Dto via From<Row> for Dto and Dto → Domain via TryFrom<Dto> for Domain.
  • Encourages newtype wrappers for IDs (e.g., UserId) and camelCase DTOs via serde.
  • Integrates validation through TryFrom and optional validator crate to guard domain invariants.
  • Prevents leaking sensitive fields by keeping password hashes in Row only and not in Dto.

Quick Start

Start by organizing each database entity into Row, Dto, and Domain modules and implement From<Row> for Dto and TryFrom<Dto> for Domain.

Frequently Asked Questions about dto-domain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I separate database rows from domain models in Rust?

Separate database rows from domain models in Rust by enforcing a three-layer pattern using Row, Dto, and Domain types. This architecture prevents internal state leakage and ensures explicit, validated conversions across service layers.

What is the best way to convert database Rows to Domain types in Rust?

The best way to convert Rows to Domain types in Rust is through an intermediate Dto. Implement From<Row> for the Dto, then use TryFrom<Dto> for the Domain type to integrate validation and guard domain invariants during creation.

How do I prevent sensitive fields like password hashes from leaking into API responses?

Prevent sensitive fields like password hashes from leaking into API responses by restricting them to the Row type only. Exclude these fields from the Dto layer entirely, ensuring they never serialize into outgoing wire formats.

How do I enforce domain validation when creating Rust entities from DTOs?

Enforce domain validation when creating Rust entities from DTOs by implementing TryFrom<Dto> for the Domain type. This conversion path requires successful validation checks, optionally using the validator crate, before instantiating the domain model.

How do I use newtype wrappers for entity IDs in Rust domain models?

Use newtype wrappers for entity IDs in Rust domain models by creating distinct types like UserId for each entity. This prevents type confusion across service layers and ensures type-safe conversions between Row, Dto, and Domain boundaries.

How do I apply camelCase serialization to Rust DTOs for API responses?

Apply camelCase serialization to Rust DTOs for API responses by configuring serde attributes on the Dto struct fields. This ensures the wire format matches typical JSON API conventions while keeping the internal Rust naming idiomatic.