Expand description
CrudService Adapter
Bridges the CrudRepository trait (from persistence) to the CrudService trait
(from HTTP layer), enabling automatic HTTP endpoint generation for any repository.
§Usage
ⓘ
use backbone_core::persistence::{InMemoryRepository, CrudServiceAdapter};
use backbone_core::{BackboneCrudHandler};
// Create repository
let repo = InMemoryRepository::<User>::new();
// Wrap with CrudServiceAdapter
let service = CrudServiceAdapter::new(
Arc::new(repo),
|dto: CreateUserDto| User { /* convert DTO to entity */ },
|entity: &mut User, dto: UpdateUserDto| { /* apply update */ },
);
// Generate all 12 HTTP endpoints
let routes = BackboneCrudHandler::<_, User, CreateUserDto, UpdateUserDto, UserResponse>
::routes(Arc::new(service), "/api/v1/users");Structs§
- Crud
Service Adapter - Adapter that wraps a
CrudRepositoryto implementCrudService - Searchable
Crud Service Adapter - Adapter for repositories that implement
SearchableRepository - Simple
Crud Service Adapter - Simple adapter for entities where Create/Update DTOs are the same as Entity
Enums§
- Adapter
Error - Error type for CrudServiceAdapter