Skip to main content

AtomicInventoryOps

Trait AtomicInventoryOps 

Source
pub trait AtomicInventoryOps<Item, Time>: InventoryRepository<Item, Time>
where Item: InventoryItem, Time: Copy + Ord,
{ // Required method fn reserve_many( &mut self, item_id: &Item::Id, slots: &[(Time, Time, u32)], ) -> Result<(), InventoryError>; }
Expand description

An extension of InventoryRepository that supports atomic operations across multiple slots.

Useful for use cases like batch reservations, where all operations must succeed together or fail entirely.

Required Methods§

Source

fn reserve_many( &mut self, item_id: &Item::Id, slots: &[(Time, Time, u32)], ) -> Result<(), InventoryError>

Attempts to reserve multiple availability slots in a single atomic operation.

If any reservation fails (due to not found or insufficient availability), no changes will be applied to any of the slots.

§Parameters
  • item_id: The ID of the item to reserve.
  • slots: A slice of (start_time, end_time, quantity) tuples to reserve.

Implementors§

Source§

impl<Item, Time> AtomicInventoryOps<Item, Time> for InMemoryInventoryRepository<Item, Time>
where Item: InventoryItem, Time: Copy + Ord + Hash + Eq, u32: From<Time>,