pub struct MaintenanceModule { /* private fields */ }Expand description
Maintenance module configuration
Use the builder pattern to configure and register this module:
let maintenance = MaintenanceModule::builder()
.with_database(pool.clone())
.build()?;
// Unguarded full CRUD (trusted/admin); compose a guarded router for production.
let router = maintenance.all_crud_routes();Implementations§
Source§impl MaintenanceModule
impl MaintenanceModule
Sourcepub fn read_only_routes(&self) -> Router
pub fn read_only_routes(&self) -> Router
The safe default route surface: full CRUD on the two benign masters (MaintenanceSchedule,
MaintenanceStage), and read-only on the engine-owned tables (MaintenanceVisit,
MaintenanceVisitPart, MaintenanceRequest) whose state must only change through
crate::MaintenanceWriteService / crate::MaintenanceRequestWriteService.
Stage CRUD is mounted in full because stages are company-agnostic master data (shared across
the fence): creating/reordering them is an administrative act with no engine invariants, and
referential safety is enforced in the DB (RESTRICT on the request FK, plus the soft-delete
guard raising maintenance_stage_in_use while any live request still sits on the stage).
Use this in place of the generated crate::MaintenanceModule::all_crud_routes, which mounts
unguarded writes on the visit/part/request tables. Direct mirror of
backbone-asset::AssetsModule::read_only_routes (CRUD on the benign master, read-only on the
engine-owned financial tables).
Sourcepub fn query_service(&self) -> Arc<dyn MaintenanceQueryService> ⓘ
pub fn query_service(&self) -> Arc<dyn MaintenanceQueryService> ⓘ
The published read contract for sibling modules — the now-implemented
crate::exports::MaintenanceQueryService over the module’s DTOs. Mirror of
backbone-asset::AssetsModule::query_service.
Sourcepub fn lifecycle_routes(&self) -> Router
pub fn lifecycle_routes(&self) -> Router
The validated, GL/inventory-backed visit write surface — plan/start/add-part/complete/cancel.
These are the only verbs that may change a visit’s state; compose the production surface as
module.read_only_routes().merge(module.lifecycle_routes()) (reads + validated writes). Do
NOT merge with crate::MaintenanceModule::all_crud_routes — both mount POST /maintenance_visits.
Requires a GlPostSink and an InventoryPort supplied via the builder
(crate::MaintenanceModuleBuilder::with_gl_sink / with_inventory_port); missing either
is a wiring error and panics at startup. The event sink defaults to LoggingSink.
Source§impl MaintenanceModule
impl MaintenanceModule
Sourcepub fn builder() -> MaintenanceModuleBuilder
pub fn builder() -> MaintenanceModuleBuilder
Create a new module builder
Sourcepub fn all_crud_routes(&self) -> Router
pub fn all_crud_routes(&self) -> Router
Mount ALL generated CRUD endpoints (12 per entity) with NO domain validation — the fully unguarded surface. A well-formed request can create invalid rows or soft-delete a referenced master out from under its dependents. Prefer a guarded composition (read + validated writes) for any real deployment; use this only in trusted/admin/seeding contexts.
Sourcepub fn routes(&self) -> Router
👎Deprecated: mounts unvalidated generic CRUD; prefer readonly_routes() + validated writes, or all_crud_routes() for the full/unguarded surface
pub fn routes(&self) -> Router
mounts unvalidated generic CRUD; prefer readonly_routes() + validated writes, or all_crud_routes() for the full/unguarded surface
Deprecated alias for Self::all_crud_routes. routes() reads like
“the routes” but mounts UNVALIDATED generic CRUD on every entity — a naive
mount exposes unguarded writes. Compose a guarded router (read + validated
writes) for production, or call all_crud_routes() to opt into the full
unguarded surface explicitly.
Sourcepub fn readonly_routes(&self) -> Router
pub fn readonly_routes(&self) -> Router
Read-only routes for every entity (GET endpoints only) — the safe base.
Generic mutation can’t reach here, so this surface cannot bypass a validated write service’s invariants. Use this as the production base and merge validated write routes (or a write service’s HTTP layer) onto it.
Auto Trait Implementations§
impl !RefUnwindSafe for MaintenanceModule
impl !UnwindSafe for MaintenanceModule
impl Freeze for MaintenanceModule
impl Send for MaintenanceModule
impl Sync for MaintenanceModule
impl Unpin for MaintenanceModule
impl UnsafeUnpin for MaintenanceModule
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