pub struct BackboneCrudHandler<S, E, C, U, R>where
S: CrudService<E, C, U> + 'static,
E: Serialize + Send + Sync + 'static,
C: DeserializeOwned + Send + Sync + 'static,
U: DeserializeOwned + Send + Sync + 'static,
R: From<E> + Serialize + Send + Sync + 'static,{ /* private fields */ }Expand description
Generic Backbone CRUD handler that provides all 11 endpoints as an Axum router.
This handler wraps a CrudService implementation and generates all standard
Backbone endpoints automatically.
§Type Parameters
S: Service implementingCrudServiceE: Entity typeC: Create DTO typeU: Update DTO typeR: Response DTO type (must implementFrom<E>)
§Example
let user_crud = UserCrudService::new(user_service);
let routes = BackboneCrudHandler::<UserCrudService, UserAggregate, CreateUserDto, UpdateUserDto, UserResponseDto>
::routes(Arc::new(user_crud), "/api/v1/users");Implementations§
Source§impl<S, E, C, U, R> BackboneCrudHandler<S, E, C, U, R>where
S: CrudService<E, C, U> + 'static,
E: Serialize + Send + Sync + Clone + EntityRepoMeta + 'static,
C: DeserializeOwned + Send + Sync + 'static,
U: DeserializeOwned + Send + Sync + 'static,
R: From<E> + Serialize + Send + Sync + 'static,
impl<S, E, C, U, R> BackboneCrudHandler<S, E, C, U, R>where
S: CrudService<E, C, U> + 'static,
E: Serialize + Send + Sync + Clone + EntityRepoMeta + 'static,
C: DeserializeOwned + Send + Sync + 'static,
U: DeserializeOwned + Send + Sync + 'static,
R: From<E> + Serialize + Send + Sync + 'static,
pub fn new(service: Arc<S>) -> Self
Sourcepub fn routes(service: Arc<S>, base_path: &str) -> Router<()>where
S: Clone,
pub fn routes(service: Arc<S>, base_path: &str) -> Router<()>where
S: Clone,
Create Axum router with all 16 Backbone endpoints (reads + writes).
Equivalent to read_routes(...).merge(write_routes(...)). Use the
split variants when reads and writes need different middleware
(e.g., public reads + authenticated writes).
§Routes Created
GET {base_path}- List with paginationPOST {base_path}- CreateGET {base_path}/:id- Get by IDPUT {base_path}/:id- Full updatePATCH {base_path}/:id- Partial updateDELETE {base_path}/:id- Soft deletePOST {base_path}/bulk- Bulk createPOST {base_path}/upsert- UpsertGET {base_path}/trash- List deleted (with filters)POST {base_path}/:id/restore- RestoreDELETE {base_path}/empty- Empty trashGET {base_path}/:id/deleted- Get deleted by IDDELETE {base_path}/trash/:id- Permanent delete from trash- (Uses route 9 with filters)
GET {base_path}/count- Count active entitiesGET {base_path}/trash/count- Count deleted entities
Sourcepub fn read_routes(service: Arc<S>, base_path: &str) -> Router<()>where
S: Clone,
pub fn read_routes(service: Arc<S>, base_path: &str) -> Router<()>where
S: Clone,
Create Axum router with only the read (GET) endpoints.
Safe to expose publicly (e.g., for reference data like countries or
categories) without auth middleware. Pair with write_routes under
an auth layer when mutations must be restricted.
§Routes Created
GET {base_path}- List with paginationGET {base_path}/:id- Get by IDGET {base_path}/trash- List deleted (with filters)GET {base_path}/:id/deleted- Get deleted by IDGET {base_path}/count- Count active entitiesGET {base_path}/trash/count- Count deleted entities
Sourcepub fn write_routes(service: Arc<S>, base_path: &str) -> Router<()>where
S: Clone,
pub fn write_routes(service: Arc<S>, base_path: &str) -> Router<()>where
S: Clone,
Create Axum router with only the write (mutation) endpoints.
These routes should not be publicly exposed. Wrap them with an auth
middleware (see BackboneCrudHandler module docs) before nesting
into the application router.
§Routes Created
POST {base_path}- CreatePOST {base_path}/bulk- Bulk createPOST {base_path}/upsert- UpsertDELETE {base_path}/empty- Empty trashDELETE {base_path}/trash/:id- Permanent delete from trashPUT {base_path}/:id- Full updatePATCH {base_path}/:id- Partial updateDELETE {base_path}/:id- Soft deletePOST {base_path}/:id/restore- Restore
Auto Trait Implementations§
impl<S, E, C, U, R> Freeze for BackboneCrudHandler<S, E, C, U, R>
impl<S, E, C, U, R> RefUnwindSafe for BackboneCrudHandler<S, E, C, U, R>
impl<S, E, C, U, R> Send for BackboneCrudHandler<S, E, C, U, R>
impl<S, E, C, U, R> Sync for BackboneCrudHandler<S, E, C, U, R>
impl<S, E, C, U, R> Unpin for BackboneCrudHandler<S, E, C, U, R>
impl<S, E, C, U, R> UnsafeUnpin for BackboneCrudHandler<S, E, C, U, R>
impl<S, E, C, U, R> UnwindSafe for BackboneCrudHandler<S, E, C, U, R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more