Skip to main content

Module adapter

Module adapter 

Source
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§

CrudServiceAdapter
Adapter that wraps a CrudRepository to implement CrudService
SearchableCrudServiceAdapter
Adapter for repositories that implement SearchableRepository
SimpleCrudServiceAdapter
Simple adapter for entities where Create/Update DTOs are the same as Entity

Enums§

AdapterError
Error type for CrudServiceAdapter