about summary refs log tree commit diff
path: root/src/librustdoc/html/static/js/stringdex.d.ts
blob: 2eb1fdf95d8454daabf21bbbe1eea4bdd56cdc1e (plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
export = stringdex;

declare namespace stringdex {
    /**
     * The client interface to Stringdex.
     */
    interface Database {
        getData(colname: string): DataColumn|undefined;
    }
    /**
     * A compressed node in the search tree.
     *
     * This object logically addresses two interleaved trees:
     * a "prefix tree", and a "suffix tree". If you ask for
     * generic matches, you get both, but if you ask for one
     * that excludes suffix-only entries, you'll get prefixes
     * alone.
     */
    interface Trie {
        matches(): RoaringBitmap;
        substringMatches(): AsyncGenerator<RoaringBitmap>;
        prefixMatches(): AsyncGenerator<RoaringBitmap>;
        keysExcludeSuffixOnly(): Uint8Array;
        childrenExcludeSuffixOnly(): [number, Promise<Trie>][];
        child(id: number): Promise<Trie>?;
    }
    /**
     * The client interface to Stringdex.
     */
    interface DataColumn {
        isEmpty(id: number): boolean;
        at(id: number): Promise<Uint8Array|undefined>;
        search(name: Uint8Array|string): Promise<Trie?>;
        searchLev(name: Uint8Array|string): AsyncGenerator<Trie>;
        length: number,
    }
    /**
     * Callbacks for a host application and VFS backend.
     *
     * These functions are calleb with mostly-raw data,
     * except the JSONP wrapper is removed. For example,
     * a file with the contents `rr_('{"A":"B"}')` should,
     * after being pulled in, result in the `rr_` callback
     * being invoked.
     *
     * The success callbacks don't need to supply the name of
     * the file that succeeded, but, if you want successful error
     * reporting, you'll need to remember which files are
     * in flight and report the filename as the first parameter.
     */
    interface Callbacks {
        /**
         * Load the root of the search database
         * @param {string} dataString
         */
        rr_: function(string);
        err_rr_: function(any);
        /**
         * Load a nodefile in the search tree.
         * A node file may contain multiple nodes;
         * each node has five fields, separated by newlines.
         * @param {string} inputBase64
         */
        rn_: function(string);
        err_rn_: function(string, any);
        /**
         * Load a database column partition from a string
         * @param {string} dataString
         */
        rd_: function(string);
        err_rd_: function(string, any);
        /**
         * Load a database column partition from base64
         * @param {string} dataString
         */
        rb_: function(string);
        err_rb_: function(string, any);
    };
    /**
     * Hooks that a VFS layer must provide for stringdex to load data.
     *
     * When the root is loaded, the Callbacks object is provided. These
     * functions should result in callback functions being called with
     * the contents of the file, or in error callbacks being invoked with
     * the failed-to-load filename.
     */
    interface Hooks {
        /**
         * The first function invoked as part of loading a search database.
         * This function must, eventually, invoke `rr_` with the string
         * representation of the root file (the function call wrapper,
         * `rr_('` and `')`, must be removed).
         *
         * The supplied callbacks object is used to feed search data back
         * to the search engine core. You have to store it, so that
         * loadTreeByHash and loadDataByNameAndHash can use it.
         *
         * If this fails, either throw an exception, or call `err_rr_`
         * with the error object.
         */
        loadRoot: function(Callbacks);
        /**
         * Load a subtree file from the search index.
         * 
         * If this function succeeds, call `rn_` on the callbacks
         * object. If it fails, call `err_rn_(hashHex, error)`.
         * 
         * @param {string} hashHex
         */
        loadTreeByHash: function(string);
        /**
         * Load a column partition from the search database.
         *
         * If this function succeeds, call `rd_` or `rb_` on the callbacks
         * object. If it fails, call `err_rd_(hashHex, error)`. or `err_rb_`.
         * To determine which one, the wrapping function call in the js file
         * specifies it.
         *
         * @param {string} columnName
         * @param {string} hashHex
         */
        loadDataByNameAndHash: function(string, string);
    };
    class RoaringBitmap {
        constructor(array: Uint8Array|null, start?: number);
        static makeSingleton(number: number);
        static everything(): RoaringBitmap;
        static empty(): RoaringBitmap;
        isEmpty(): boolean;
        union(that: RoaringBitmap): RoaringBitmap;
        intersection(that: RoaringBitmap): RoaringBitmap;
        contains(number: number): boolean;
        entries(): Generator<number>;
        first(): number|null;
        consumed_len_bytes: number;
    };

    type Stringdex = {
        /**
         * Initialize Stringdex with VFS hooks.
         * Returns a database that you can use.
         */
        loadDatabase: function(Hooks): Promise<Database>,
    };

    const Stringdex: Stringdex;
    const RoaringBitmap: Class<stringdex.RoaringBitmap>;
}

declare global {
    interface Window {
        Stringdex: stringdex.Stringdex;
        RoaringBitmap: Class<stringdex.RoaringBitmap>;
        StringdexOnload: Array<function(stringdex.Stringdex): any>?;
    };
}