ic_storage/adapter/
error.rs1#[derive(Clone, Copy, Debug, Eq, PartialEq, thiserror::Error)]
9pub enum CollectionError {
10 #[error("unrecognized collection format")]
12 Format,
13 #[error("collection growth refused")]
15 Growth,
16 #[error("collection memory is not empty")]
18 NotEmpty,
19 #[error("{0}")]
21 Cell(#[from] crate::StableCellPayloadError),
22}
23
24pub(super) type Result<T> = std::result::Result<T, CollectionError>;
25
26pub(super) const fn ensure(condition: bool, error: CollectionError) -> Result<()> {
27 if condition { Ok(()) } else { Err(error) }
28}