esp_nvs/
error.rs

1use crate::raw;
2
3pub use raw::ItemType;
4
5/// Errors that can occur during NVS operations. The list is likely to stay as is but marked as
6/// non-exhaustive to allow for future additions without breaking the API. A caller would likely only
7/// need to handle NamespaceNotFound and KeyNotFound as the other errors are static.
8#[derive(Debug, PartialEq)]
9#[cfg_attr(feature = "defmt", derive(defmt::Format))]
10#[non_exhaustive]
11pub enum Error {
12    /// The partition offset has to be aligned to the size of a flash sector (4k)
13    InvalidPartitionOffset,
14    /// The partition size has to be a multiple of the flash sector size (4k)
15    InvalidPartitionSize,
16    /// The internal error value is returned from the provided `&mut impl flash::Flash`
17    FlashError,
18    /// Namespace not found. Either the flash was corrupted and silently fixed on
19    /// startup or no value has been written yet.
20    NamespaceNotFound,
21    /// The max namespace length is 15 bytes plus null terminator.
22    NamespaceTooLong,
23    /// The namespace is malformed. The last byte must be b'\0'
24    NamespaceMalformed,
25    /// Strings are limited to `MAX_BLOB_DATA_PER_PAGE` while blobs can be up to `MAX_BLOB_SIZE` bytes
26    ValueTooLong,
27    /// The key is malformed. The last byte must be b'\0'
28    KeyMalformed,
29    /// The max key length is 15 bytes plus null terminator.
30    KeyTooLong,
31    /// Key not found. Either the flash was corrupted and silently fixed on or no value has been written yet.
32    KeyNotFound,
33    /// The encountered item type is reported
34    ItemTypeMismatch(ItemType),
35    /// Blob data is corrupted or inconsistent
36    CorruptedData,
37    /// Flash is full and defragmentation doesn't help.
38    FlashFull,
39    /// Used internally to indicate that we have to allocate a new page.
40    PageFull,
41}