1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
#[cfg(feature = "api-store-fragment")]
mod fragment;
pub(crate) fn new() -> Item {
let docs = docs! {
/// Persistent storage operations.
};
let name = "store".into();
let items = vec![
#[cfg(feature = "api-store")]
item! {
/// Inserts an entry in the store.
///
/// If an entry for that key was already present, it is overwritten.
fn insert "si" {
/// Key of the entry.
///
/// This must be smaller than 4096.
key: usize,
/// Value of the entry.
ptr: *const u8,
/// Length of the value.
len: usize,
} -> ()
},
#[cfg(feature = "api-store")]
item! {
/// Removes an entry from the store.
///
/// This is not an error if no entry is present. This is simply a no-op in that case.
fn remove "sr" {
/// Key of the entry.
key: usize,
} -> ()
},
#[cfg(feature = "api-store")]
item! {
/// Finds an entry in the store, if any.
///
/// Returns whether an entry was found.
///
/// This is an [allocating function](crate#allocating-memory).
fn find "sf" {
/// Key of the entry to find.
key: usize,
/// Where to write the value of the entry, if found.
ptr: *mut *mut u8,
/// Where to write the length of the value, if found.
len: *mut usize,
} -> bool
},
#[cfg(feature = "api-store")]
item! {
/// Returns the unordered keys of the entries in the store.
///
/// This is an [allocating function](crate#allocating-memory) returning the number of
/// keys (thus half the number of allocated bytes).
fn keys "sk" {
/// Where to write the keys as an array of u16.
ptr: *mut *mut u8,
} -> usize
},
#[cfg(feature = "api-store")]
item! {
/// Clears the store, removing all entries.
fn clear "sc" {} -> ()
},
#[cfg(feature = "api-store-fragment")]
fragment::new(),
];
Item::Mod(Mod { docs, name, items })
}