Crate docsearch

source ·
Expand description

Use the latest search index from rustdoc to find the docs.rs (or stdlib) URL for any item in a crate by its simple path.

Example

Please have a look at the start_search function for an example of how to use this crate, as it is the main entry point. In addition, you can check out the examples directory in the repository.

Feature flags

The following features flags enable support for older versions of the search index. If they’re not enabled, the retrieving the Index for a crate might fail. These should be enabled or disabled based on the requirements to what crates will be searched for (if known).

The features listed are enabled by default.

  • index-v2 enables support to parse the slightly outdated index format. This is needed if parsing of older crates that haven’t be update in a while is required.
  • index-v1 enables support for the even older index format. Nowadays it’s rarely found and this is only needed to parse very old crates that haven’t been updated in a long while.

Modules

  • Different types of errors that can occur when using this crate.

Structs

  • Parsed crate index that contains the mappings from SimplePaths to their URL for direct linking.
  • Second and last state in retrieving a search index. Use the Self::url function to get the search index URL to download. The index’s content must be passed to Self::transform_index to create the final Index instance.
  • Initial state when starting a new search. Use the Self::url function to get the URL to download content from. The web page content must then be passed to Self::find_index to get to the next state.
  • Path for any item within a crate (or just the crate itself) like std::vec::Vec, anyhow::Result or thiserror.

Enums

  • Crate version that can be either the latest available or a specific one.

Functions

  • Search for the given crate name and optionally a fixed version. This is the main entry point to retrieve an Index and further query that index for SimplePaths.