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
//! Bindings to the `bookmarks` API.

use js_sys::{Array, Number};
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
extern "C" {
    pub type Bookmarks;

    #[wasm_bindgen(method)]
    pub async fn get(this: &Bookmarks, id_or_list: &JsValue) -> JsValue;

    #[wasm_bindgen(method)]
    pub async fn search(this: &Bookmarks, query: &JsValue) -> JsValue;
}

#[wasm_bindgen]
extern "C" {

    // A node (either a bookmark or a folder) in the bookmark tree.
    pub type BookmarkTreeNode;

    // An ordered list of children of this node.
    #[wasm_bindgen(method)]
    pub fn children(this: &BookmarkTreeNode) -> Option<Array>;

    // When this node was created, in milliseconds since the epoch (new Date(dateAdded)).
    #[wasm_bindgen(method, js_name = dateAdded)]
    pub fn date_added(this: &BookmarkTreeNode) -> Option<Number>;

    // When the contents of this folder last changed, in milliseconds since the epoch.
    #[wasm_bindgen(method, js_name = dateGroupModified)]
    pub fn date_group_modified(this: &BookmarkTreeNode) -> Option<Number>;

    // The unique identifier for the node. IDs are unique within the current profile, and they remain valid even after the browser is restarted.
    #[wasm_bindgen(method)]
    pub fn id(this: &BookmarkTreeNode) -> String;

    // The 0-based position of this node within its parent folder.
    #[wasm_bindgen(method)]
    pub fn index(this: &BookmarkTreeNode) -> Option<Number>;

    // The id of the parent folder. Omitted for the root node.
    #[wasm_bindgen(method, js_name = parentId)]
    pub fn parent_id(this: &BookmarkTreeNode) -> Option<String>;

    // The text displayed for the node.
    #[wasm_bindgen(method)]
    pub fn title(this: &BookmarkTreeNode) -> String;

    // Indicates the reason why this node is unmodifiable.
    #[wasm_bindgen(method)]
    pub fn unmodifiable(this: &BookmarkTreeNode) -> Option<String>;

    // The URL navigated to when a user clicks the bookmark. Omitted for folders.
    #[wasm_bindgen(method)]
    pub fn url(this: &BookmarkTreeNode) -> Option<String>;

}