Order fulfillment, scheduling, and delivery for Rust applications
| Tier | domain |
| Role | unclassified (baselined) |
| Path | crates/domain/fulfillment |
| Edition | 2021 |
| Targets | domain_fulfillment |
| Public items | 90 across 0 modules |
| Tests | 18 |
What it is for
Fulfillment library crates for order processing, scheduling, and delivery.
This module provides generic types for managing order fulfillment workflows:
- Orders and order items with status tracking
- Fulfillment plans with multiple delivery modes
- Service legs for pickup/delivery operations
- Runs for scheduling and routing
# Example
use domain_fulfillment::{Order, OrderStatus, FulfillmentMode, FulfillmentPlan};
use uuid::Uuid;
// Create an order
let order = Order::new(Uuid::new_v4());
// Create a fulfillment plan
let plan = FulfillmentPlan::new(order.id, FulfillmentMode::Delivery);
Capabilities
FulfillmentError
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum FulfillmentError |
FulfillmentMode
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum FulfillmentMode |
FulfillmentMode :: fn requires_delivery(& self) -> bool |
FulfillmentMode :: fn requires_pickup(& self) -> bool |
FulfillmentMode :: fn requires_routing(& self) -> bool |
FulfillmentMode :: fn required_legs(& self) -> Vec <LegType> |
FulfillmentMode :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
FulfillmentPlan
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub struct FulfillmentPlan |
FulfillmentPlan :: fn new(order_id : Uuid, mode : FulfillmentMode) -> Self |
FulfillmentPlan :: fn with_default_legs(order_id : Uuid, mode : FulfillmentMode) -> Self |
FulfillmentPlan :: fn add_leg(& mut self, leg : ServiceLeg) -> Result <()> |
FulfillmentPlan :: fn start(& mut self) |
FulfillmentPlan :: fn complete(& mut self) |
FulfillmentPlan :: fn cancel(& mut self) |
FulfillmentPlan :: fn pending_leg_count(& self) -> usize |
FulfillmentPlan :: fn completed_leg_count(& self) -> usize |
FulfillmentStatus
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum FulfillmentStatus |
FulfillmentStatus :: fn is_terminal(& self) -> bool |
FulfillmentStatus :: fn can_modify_legs(& self) -> bool |
FulfillmentStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
LegStatus
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum LegStatus |
LegStatus :: fn is_terminal(& self) -> bool |
LegStatus :: fn can_reassign(& self) -> bool |
LegStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
LegType
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum LegType |
LegType :: fn is_routed(& self) -> bool |
LegType :: fn is_customer_action(& self) -> bool |
LegType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
Order:Order
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub struct Order |
Order:add
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn add_item(& mut self, item : OrderItem) |
Order:cancel
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn cancel(& mut self) -> Result <()> |
Order:complete
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn complete(& mut self) -> Result <()> |
Order:fulfilled
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn fulfilled_item_count(& self) -> usize |
Order:hold
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn hold(& mut self, reason : Option <String>) |
Order:item
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn item_count(& self) -> usize |
Order:mark
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn mark_ready(& mut self) -> Result <()> |
Order:new
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn new(customer_id : Uuid) -> Self |
Order:start
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn start_processing(& mut self) -> Result <()> |
Order:submit
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn submit(& mut self) -> Result <()> |
Order:with
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Order :: fn with_order_number(mut self, number : impl Into <String>) -> Self |
Order :: fn with_requested_date(mut self, date : NaiveDate) -> Self |
OrderItem
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub struct OrderItem |
OrderItem :: fn new(order_id : Uuid, name : impl Into <String>, quantity : i32) -> Self |
OrderItem :: fn with_catalog_item(mut self, catalog_item_id : Uuid) -> Self |
OrderItem :: fn with_unit_price(mut self, cents : i64) -> Self |
OrderItem :: fn total_cents(& self) -> Option <i64> |
OrderItem :: fn fulfill(& mut self) |
OrderItem :: fn cancel(& mut self) |
OrderItemStatus
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum OrderItemStatus |
OrderItemStatus :: fn is_terminal(& self) -> bool |
OrderItemStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
OrderStatus
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum OrderStatus |
OrderStatus :: fn is_terminal(& self) -> bool |
OrderStatus :: fn is_modifiable(& self) -> bool |
OrderStatus :: fn can_cancel(& self) -> bool |
OrderStatus :: fn valid_transitions(& self) -> Vec <OrderStatus> |
OrderStatus :: fn can_transition_to(& self, target : OrderStatus) -> bool |
OrderStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
Result
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub type Result<T>: std::result::Result <T, FulfillmentError> |
Run:Run
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub struct Run |
Run:add
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn add_leg(& mut self, leg_id : Uuid) -> Result <()> |
Run:cancel
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn cancel(& mut self) |
Run:complete
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn complete(& mut self) |
Run:leg
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn leg_count(& self) -> usize |
Run:lock
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn lock(& mut self) |
Run:new
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn new(scheduled_date : NaiveDate) -> Self |
Run:publish
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn publish(& mut self) |
Run:remove
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn remove_leg(& mut self, leg_id : Uuid) -> Result <()> |
Run:start
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn start(& mut self) |
Run:with
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
Run :: fn with_name(mut self, name : impl Into <String>) -> Self |
Run :: fn with_driver(mut self, driver_id : Uuid) -> Self |
Run :: fn with_vehicle(mut self, vehicle_id : Uuid) -> Self |
RunStatus
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum RunStatus |
RunStatus :: fn allows_leg_changes(& self) -> bool |
RunStatus :: fn is_modifiable(& self) -> bool |
RunStatus :: fn is_terminal(& self) -> bool |
RunStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
ServiceLeg
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub struct ServiceLeg |
ServiceLeg :: fn new(plan_id : Uuid, leg_type : LegType) -> Self |
ServiceLeg :: fn assign_to_run(& mut self, run_id : Uuid) -> Result <()> |
ServiceLeg :: fn start(& mut self) |
ServiceLeg :: fn complete(& mut self) |
ServiceLeg :: fn fail(& mut self, reason : Option <String>) |
ServiceLeg :: fn skip(& mut self, reason : Option <String>) |
ServiceLeg :: fn duration(& self) -> Option <chrono::Duration> |
StopType
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub enum StopType |
StopType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
TimeSlot
Fulfillment library crates for order processing, scheduling, and delivery.
| Item |
|---|
pub struct TimeSlot |
TimeSlot :: fn new(name : impl Into <String>, start : NaiveTime, end : NaiveTime) -> Self |
TimeSlot :: fn duration_minutes(& self) -> i64 |
How to use it
From this crate's own rustdoc:
use domain_fulfillment::{Order, OrderStatus, FulfillmentMode, FulfillmentPlan};
use uuid::Uuid;
// Create an order
let order = Order::new(Uuid::new_v4());
// Create a fulfillment plan
let plan = FulfillmentPlan::new(order.id, FulfillmentMode::Delivery);
Module structure
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
pub enum FulfillmentError | Errors that can occur during fulfillment operations. |
pub type Result<T>: std::result::Result <T, FulfillmentError> | Result type for fulfillment operations. |
pub enum OrderStatus | Status of an order in the fulfillment pipeline. |
OrderStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
OrderStatus :: fn is_modifiable(& self) -> bool | Check if the order can be modified. |
OrderStatus :: fn can_cancel(& self) -> bool | Check if the order can be cancelled. |
OrderStatus :: fn valid_transitions(& self) -> Vec <OrderStatus> | Get valid next statuses from current status. |
OrderStatus :: fn can_transition_to(& self, target : OrderStatus) -> bool | Check if transition to target status is valid. |
OrderStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum OrderItemStatus | Status of an individual order item. |
OrderItemStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
OrderItemStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum FulfillmentMode | How the order will be fulfilled (delivery method). |
FulfillmentMode :: fn requires_delivery(& self) -> bool | Check if this mode requires physical delivery. |
FulfillmentMode :: fn requires_pickup(& self) -> bool | Check if this mode requires pickup from customer. |
FulfillmentMode :: fn requires_routing(& self) -> bool | Check if this mode requires routing/scheduling. |
FulfillmentMode :: fn required_legs(& self) -> Vec <LegType> | Get the leg types needed for this fulfillment mode. |
FulfillmentMode :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum FulfillmentStatus | Status of a fulfillment plan. |
FulfillmentStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
FulfillmentStatus :: fn can_modify_legs(& self) -> bool | Check if plan can have legs modified. |
FulfillmentStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum LegType | Type of service leg in a fulfillment plan. |
LegType :: fn is_routed(& self) -> bool | Check if this leg type requires routing. |
LegType :: fn is_customer_action(& self) -> bool | Check if this leg involves customer coming to location. |
LegType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum LegStatus | Status of a service leg. |
LegStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
LegStatus :: fn can_reassign(& self) -> bool | Check if leg can be reassigned. |
LegStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub enum RunStatus | Status of a delivery/pickup run. |
RunStatus :: fn allows_leg_changes(& self) -> bool | Check if the run can have legs assigned/removed. |
RunStatus :: fn is_modifiable(& self) -> bool | Check if run is modifiable at all. |
RunStatus :: fn is_terminal(& self) -> bool | Check if this is a terminal status. |
RunStatus :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub struct TimeSlot | Time slot for scheduling deliveries/pickups. |
TimeSlot :: fn new(name : impl Into <String>, start : NaiveTime, end : NaiveTime) -> Self | Create a new time slot. |
TimeSlot :: fn duration_minutes(& self) -> i64 | Get slot duration in minutes. |
pub enum StopType | Type of stop/location. |
StopType :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
pub struct Order | An order for fulfillment. |
Order :: fn new(customer_id : Uuid) -> Self | Create a new order. |
Order :: fn with_order_number(mut self, number : impl Into <String>) -> Self | Set order number. |
Order :: fn with_requested_date(mut self, date : NaiveDate) -> Self | Set requested date. |
Order :: fn add_item(& mut self, item : OrderItem) | Add an item to the order. |
Order :: fn submit(& mut self) -> Result <()> | Submit the order. |
Order :: fn start_processing(& mut self) -> Result <()> | Start processing the order. |
Order :: fn mark_ready(& mut self) -> Result <()> | Mark order as ready. |
Order :: fn complete(& mut self) -> Result <()> | Complete the order. |
Order :: fn cancel(& mut self) -> Result <()> | Cancel the order. |
Order :: fn hold(& mut self, reason : Option <String>) | Put order on hold. |
Order :: fn item_count(& self) -> usize | Get count of items. |
Order :: fn fulfilled_item_count(& self) -> usize | Get count of fulfilled items. |
pub struct OrderItem | An item within an order. |
OrderItem :: fn new(order_id : Uuid, name : impl Into <String>, quantity : i32) -> Self | Create a new order item. |
OrderItem :: fn with_catalog_item(mut self, catalog_item_id : Uuid) -> Self | Set catalog item reference. |
OrderItem :: fn with_unit_price(mut self, cents : i64) -> Self | Set unit price. |
OrderItem :: fn total_cents(& self) -> Option <i64> | Calculate total price in cents. |
OrderItem :: fn fulfill(& mut self) | Mark item as fulfilled. |
OrderItem :: fn cancel(& mut self) | Cancel the item. |
pub struct FulfillmentPlan | A plan for fulfilling an order. |
FulfillmentPlan :: fn new(order_id : Uuid, mode : FulfillmentMode) -> Self | Create a new fulfillment plan. |
FulfillmentPlan :: fn with_default_legs(order_id : Uuid, mode : FulfillmentMode) -> Self | Create a plan with auto-generated legs based on mode. |
FulfillmentPlan :: fn add_leg(& mut self, leg : ServiceLeg) -> Result <()> | Add a service leg. |
FulfillmentPlan :: fn start(& mut self) | Start the plan. |
FulfillmentPlan :: fn complete(& mut self) | Complete the plan. |
FulfillmentPlan :: fn cancel(& mut self) | Cancel the plan. |
FulfillmentPlan :: fn pending_leg_count(& self) -> usize | Get count of pending legs. |
FulfillmentPlan :: fn completed_leg_count(& self) -> usize | Get count of completed legs. |
pub struct ServiceLeg | A single leg of a fulfillment plan (e.g., delivery, pickup). |
ServiceLeg :: fn new(plan_id : Uuid, leg_type : LegType) -> Self | Create a new service leg. |
ServiceLeg :: fn assign_to_run(& mut self, run_id : Uuid) -> Result <()> | Assign to a run. |
ServiceLeg :: fn start(& mut self) | Start the leg. |
ServiceLeg :: fn complete(& mut self) | Complete the leg. |
ServiceLeg :: fn fail(& mut self, reason : Option <String>) | Fail the leg. |
ServiceLeg :: fn skip(& mut self, reason : Option <String>) | Skip the leg. |
ServiceLeg :: fn duration(& self) -> Option <chrono::Duration> | Get duration if completed. |
pub struct Run | A delivery/pickup run containing multiple legs. |
Run :: fn new(scheduled_date : NaiveDate) -> Self | Create a new run. |
Run :: fn with_name(mut self, name : impl Into <String>) -> Self | Set name. |
Run :: fn with_driver(mut self, driver_id : Uuid) -> Self | Set driver. |
Run :: fn with_vehicle(mut self, vehicle_id : Uuid) -> Self | Set vehicle. |
Run :: fn add_leg(& mut self, leg_id : Uuid) -> Result <()> | Add a leg to the run. |
Run :: fn remove_leg(& mut self, leg_id : Uuid) -> Result <()> | Remove a leg from the run. |
Run :: fn publish(& mut self) | Publish the run. |
Run :: fn lock(& mut self) | Lock the run. |
Run :: fn start(& mut self) | Start the run. |
Run :: fn complete(& mut self) | Complete the run. |
Run :: fn cancel(& mut self) | Cancel the run. |
Run :: fn leg_count(& self) -> usize | Get leg count. |
No pub use re-exports: every item above is declared in this crate.
Boundary
Depends on no other workspace tier.
Shares tier domain with 41 other crates: domain-agreements, domain-ai-report, domain-billing, domain-catalog, domain-classify, domain-comments, domain-competitive-intel, domain-contact, … (41 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | domain |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/domain/fulfillment |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
chrono | ^0.4 | serde | no | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_fulfillment["application-fulfillment"] -->|uses| SELF SELF["domain-fulfillment"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | domain_fulfillment | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
FulfillmentError | Result |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: application-fulfillment.
Verification
| Kind | Count |
|---|---|
| Unit tests | 18 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 1 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 16 | 0 | 4 |
What the tests establish, by name:
test_fulfillment_mode_required_legs—src/lib.rstest_fulfillment_mode_routing—src/lib.rstest_fulfillment_plan_creation—src/lib.rstest_fulfillment_status—src/lib.rstest_leg_skip—src/lib.rstest_leg_type_routed—src/lib.rstest_order_cancellation—src/lib.rstest_order_creation_and_flow—src/lib.rstest_order_hold—src/lib.rstest_order_item_status—src/lib.rstest_order_items—src/lib.rstest_order_status_terminal—src/lib.rstest_order_status_transitions—src/lib.rstest_plan_completion—src/lib.rstest_run_lifecycle—src/lib.rstest_run_status_modifiable—src/lib.rstest_service_leg_lifecycle—src/lib.rstest_time_slot—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 82 | 90 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 82
"No rustdoc detected" : 8
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 1325 |
| Code lines | 968 |
| Public API items | 90 |
| Public modules | 0 |
| Tests | 18 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 5 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"enum" : 9
"method" : 74
"struct" : 6
"type alias" : 1
pie showData
title Rust source composition
"Code" : 968
"Blank or comment" : 357
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.