internal-storage.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #include <stddef.h>
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. /* Internal storage state */
  6. typedef enum {
  7. InternalStorageStateInitializing,
  8. InternalStorageStateReady,
  9. InternalStorageStateBroken,
  10. } InternalStorageState;
  11. typedef struct InternalStorage InternalStorage;
  12. /** Read key, blocking api
  13. * @param internal_storage - InternalStorage instance
  14. * @param key - file name to read data from
  15. * @param buffer - pointer to data buffer
  16. * @param size - buffer size
  17. * @return negative on error, otherwise data read
  18. */
  19. int internal_storage_read_key(
  20. InternalStorage* internal_storage,
  21. const char* key,
  22. uint8_t* buffer,
  23. size_t size);
  24. /** Write key, blocking api
  25. * @param internal_storage - InternalStorage instance
  26. * @param key - file name to store data to
  27. * @param buffer - pointer to data buffer
  28. * @param size - buffer size
  29. * @return negative on error, otherwise data written
  30. */
  31. int internal_storage_write_key(
  32. InternalStorage* internal_storage,
  33. const char* key,
  34. uint8_t* buffer,
  35. size_t size);