web_extensions_sys/
bookmarks.rs

1//! Bindings to the `bookmarks` API.
2
3use js_sys::{Array, Number};
4use wasm_bindgen::prelude::*;
5
6#[wasm_bindgen]
7extern "C" {
8    pub type Bookmarks;
9
10    #[wasm_bindgen(method)]
11    pub async fn get(this: &Bookmarks, id_or_list: &JsValue) -> JsValue;
12
13    #[wasm_bindgen(method)]
14    pub async fn search(this: &Bookmarks, query: &JsValue) -> JsValue;
15}
16
17#[wasm_bindgen]
18extern "C" {
19
20    // A node (either a bookmark or a folder) in the bookmark tree.
21    pub type BookmarkTreeNode;
22
23    // An ordered list of children of this node.
24    #[wasm_bindgen(method)]
25    pub fn children(this: &BookmarkTreeNode) -> Option<Array>;
26
27    // When this node was created, in milliseconds since the epoch (new Date(dateAdded)).
28    #[wasm_bindgen(method, js_name = dateAdded)]
29    pub fn date_added(this: &BookmarkTreeNode) -> Option<Number>;
30
31    // When the contents of this folder last changed, in milliseconds since the epoch.
32    #[wasm_bindgen(method, js_name = dateGroupModified)]
33    pub fn date_group_modified(this: &BookmarkTreeNode) -> Option<Number>;
34
35    // The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted.
36    #[wasm_bindgen(method)]
37    pub fn id(this: &BookmarkTreeNode) -> String;
38
39    // The 0-based position of this node within its parent folder.
40    #[wasm_bindgen(method)]
41    pub fn index(this: &BookmarkTreeNode) -> Option<Number>;
42
43    // The id of the parent folder. Omitted for the root node.
44    #[wasm_bindgen(method, js_name = parentId)]
45    pub fn parent_id(this: &BookmarkTreeNode) -> Option<String>;
46
47    // The text displayed for the node.
48    #[wasm_bindgen(method)]
49    pub fn title(this: &BookmarkTreeNode) -> String;
50
51    // Indicates the reason why this node is unmodifiable.
52    #[wasm_bindgen(method)]
53    pub fn unmodifiable(this: &BookmarkTreeNode) -> Option<String>;
54
55    // The URL navigated to when a user clicks the bookmark. Omitted for folders.
56    #[wasm_bindgen(method)]
57    pub fn url(this: &BookmarkTreeNode) -> Option<String>;
58
59}