fix: 对不支持weak的bsp, luat_http_client_onevent报重复定义了
[LuatOS.git] / components / fskv / luat_fskv.h
blobbd424243db576f6b03f3e2542113e7ed8732e5b3
1 /*
2 * Copyright (c) 2022 OpenLuat & AirM2M
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of
5 * this software and associated documentation files (the "Software"), to deal in
6 * the Software without restriction, including without limitation the rights to
7 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 * the Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #ifndef LUAT_FSKV_H
23 #define LUAT_FSKV_H
25 #include "lfs.h"
29 /**
30 * @defgroup luatos_fskv 持久化数据存储接口
31 * @{
34 /**
35 * @brief 初始化kv数据存储
37 * @return int == 0 正常 != 0失败
39 int luat_fskv_init(void);
41 /**
42 * @brief 删除指定的key
43 * @param key[IN] 待删除的key值
44 * @return int == 0 正常 != 0失败
46 int luat_fskv_del(const char* key);
48 /**
49 * @brief 写入指定key的数据
50 * @param key[IN] 待写入的key值,不能为NULL,必须是\0结尾,最大长度64字节
51 * @param data[IN] 待写入的数据, 不需要\0结尾
52 * @param len[IN] 待写入的数据长度, 不含\0,当前支持最大长度255字节
53 * @return 实际写入的长度
55 int luat_fskv_set(const char* key, void* data, size_t len);
57 /**
58 * @brief 读取key大小
59 * @param key key值,不能为NULL,必须是\0结尾,最大长度64字节
60 * @param buff 缓冲区
61 * @return 长度,<=0 失败
63 int luat_fskv_size(const char* key, char buff[4]);
65 /**
66 * @brief 读取指定key的数据
67 * @param key[IN] 待读取的key值,不能为NULL,必须是\0结尾
68 * @param data[IN] 待读取的数据, 可写入空间必须大于等于len值
69 * @param len[IN] 待读取的数据长度最大长度, 不含\0
70 * @return int > 0 实际读取的长度, <=0 失败
72 int luat_fskv_get(const char* key, void* data, size_t len);
74 /**
75 * @brief 清空所有数据
76 * @return int == 0 正常 != 0失败
78 int luat_fskv_clear(void);
79 /**
80 * @brief 获取kv数据库状态
81 * @param using_sz 已使用的空间,单位字节
82 * @param max_sz 总可用空间, 单位字节
83 * @param kv_count 总kv键值对数量, 单位个
84 * @return 0 成功,其他失败
86 int luat_fskv_stat(size_t *using_sz, size_t *max_sz, size_t *kv_count);
87 /**
88 * @brief 读取下一个偏移的数据
89 * @param buff 读取数据
90 * @param offset 偏移
91 * @return 0 成功,其他失败
93 int luat_fskv_next(char* buff, size_t offset);
95 /**
96 * @}
99 #endif