-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import CrateDocManager from "../../crate-manager.js"; | ||
import IndexManager from "../../index-manager.js"; | ||
|
||
class DescShardManager { | ||
constructor() { | ||
// A crate -> desc shard map. | ||
this.descShards = new Map(); | ||
} | ||
|
||
async initDescShards() { | ||
for (const crate of Object.keys(await CrateDocManager.getCrates())) { | ||
const descShards = await IndexManager.getDescShards(crate); | ||
this.descShards.set(crate, descShards); | ||
} | ||
} | ||
|
||
|
||
// Load a single desc shard. | ||
// Compatible with librustdoc main.js. | ||
async loadDesc({ descShard, descIndex }) { | ||
let crateDescShard = this.descShards.get(descShard.crate); | ||
if (!crateDescShard || crateDescShard.length === 0) { | ||
return null; | ||
} | ||
return crateDescShard[descShard.shard][descIndex]; | ||
} | ||
} | ||
|
||
const searchState = new DescShardManager(); | ||
export default searchState; |