pub struct MaintenanceWriteService { /* private fields */ }Implementations§
Source§impl MaintenanceWriteService
impl MaintenanceWriteService
pub fn new(pool: PgPool) -> Self
Sourcepub async fn create_schedule(
&self,
s: NewSchedule,
) -> Result<Uuid, MaintenanceError>
pub async fn create_schedule( &self, s: NewSchedule, ) -> Result<Uuid, MaintenanceError>
Define a preventive maintenance schedule for an asset.
Sourcepub async fn plan_visit(&self, v: NewVisit) -> Result<Uuid, MaintenanceError>
pub async fn plan_visit(&self, v: NewVisit) -> Result<Uuid, MaintenanceError>
Plan a visit (planned). Preventive visits reference a schedule; corrective ones don’t.
Sourcepub async fn add_part(
&self,
visit_id: Uuid,
item_id: Uuid,
quantity: Decimal,
) -> Result<Uuid, MaintenanceError>
pub async fn add_part( &self, visit_id: Uuid, item_id: Uuid, quantity: Decimal, ) -> Result<Uuid, MaintenanceError>
Add a part line to a planned/in-progress visit (quantity only; valued on completion).
Sourcepub async fn start_visit(&self, visit_id: Uuid) -> Result<(), MaintenanceError>
pub async fn start_visit(&self, visit_id: Uuid) -> Result<(), MaintenanceError>
Start a planned visit (planned → in_progress).
Sourcepub async fn complete_visit(
&self,
visit_id: Uuid,
performed_date: NaiveDate,
inventory: &dyn InventoryPort,
sink: &dyn GlPostSink,
events: &dyn MaintenanceEventSink,
) -> Result<CompleteOutcome, MaintenanceError>
pub async fn complete_visit( &self, visit_id: Uuid, performed_date: NaiveDate, inventory: &dyn InventoryPort, sink: &dyn GlPostSink, events: &dyn MaintenanceEventSink, ) -> Result<CompleteOutcome, MaintenanceError>
Complete a visit: issue its parts (valued by inventory), roll up the cost, post ONE balanced
maintenance-cost journal, and gate → completed. Posts at most once (idempotent on source_id = visit_id). A zero-cost visit completes without a posting. Emits MaintenanceCompleted.
Sourcepub async fn cancel_visit(&self, visit_id: Uuid) -> Result<(), MaintenanceError>
pub async fn cancel_visit(&self, visit_id: Uuid) -> Result<(), MaintenanceError>
Cancel a planned/in-progress visit.
Auto Trait Implementations§
impl !RefUnwindSafe for MaintenanceWriteService
impl !UnwindSafe for MaintenanceWriteService
impl Freeze for MaintenanceWriteService
impl Send for MaintenanceWriteService
impl Sync for MaintenanceWriteService
impl Unpin for MaintenanceWriteService
impl UnsafeUnpin for MaintenanceWriteService
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
Mutably borrows from an owned value. Read more
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> ⓘ
Converts
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> ⓘ
Converts
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