#[non_exhaustive]pub enum InventoryError {
ItemNotFound(String),
InsufficientStock {
sku: String,
requested: String,
available: String,
},
ReservationNotFound(Uuid),
ReservationExpired(Uuid),
DuplicateSku(String),
Other(Box<dyn Error + Send + Sync>),
}Expand description
Errors specific to inventory operations.
§Example
use stateset_core::errors::InventoryError;
let err = InventoryError::insufficient_stock("SKU-001", "10", "3");
assert!(err.to_string().contains("SKU-001"));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
ItemNotFound(String)
Inventory item not found by SKU or ID.
InsufficientStock
Insufficient stock for the requested quantity.
Fields
ReservationNotFound(Uuid)
Inventory reservation not found.
ReservationExpired(Uuid)
Inventory reservation has expired.
DuplicateSku(String)
Duplicate SKU already exists.
Other(Box<dyn Error + Send + Sync>)
Extensibility.
Implementations§
Source§impl InventoryError
impl InventoryError
Sourcepub fn item_not_found(id: impl Into<String>) -> Self
pub fn item_not_found(id: impl Into<String>) -> Self
Convenience constructor for ItemNotFound.
Sourcepub fn insufficient_stock(
sku: impl Into<String>,
requested: impl Into<String>,
available: impl Into<String>,
) -> Self
pub fn insufficient_stock( sku: impl Into<String>, requested: impl Into<String>, available: impl Into<String>, ) -> Self
Convenience constructor for InsufficientStock.
Sourcepub const fn reservation_not_found(id: Uuid) -> Self
pub const fn reservation_not_found(id: Uuid) -> Self
Convenience constructor for ReservationNotFound.
Sourcepub const fn reservation_expired(id: Uuid) -> Self
pub const fn reservation_expired(id: Uuid) -> Self
Convenience constructor for ReservationExpired.
Sourcepub fn duplicate_sku(sku: impl Into<String>) -> Self
pub fn duplicate_sku(sku: impl Into<String>) -> Self
Convenience constructor for DuplicateSku.
Trait Implementations§
Source§impl Debug for InventoryError
impl Debug for InventoryError
Source§impl Display for InventoryError
impl Display for InventoryError
Source§impl Error for InventoryError
impl Error for InventoryError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<InventoryError> for CommerceError
impl From<InventoryError> for CommerceError
Source§fn from(source: InventoryError) -> Self
fn from(source: InventoryError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for InventoryError
impl !UnwindSafe for InventoryError
impl Freeze for InventoryError
impl Send for InventoryError
impl Sync for InventoryError
impl Unpin for InventoryError
impl UnsafeUnpin for InventoryError
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