Skip to main content

CrateNames

Struct CrateNames 

Source
pub struct CrateNames(/* private fields */);
Expand description

Reader for the names artifact (names-v1.tsv.zst): every crate name with its default version and download rank.

Implementations§

Source§

impl CrateNames

Source

pub fn from_zstd(bytes: &[u8]) -> Result<Self, Error>

Parse a zstd-compressed names artifact.

Source

pub fn from_tsv(text: String) -> Result<Self, Error>

Parse an already-decompressed names artifact.

Source

pub fn len(&self) -> usize

Number of crates in the artifact.

Source

pub fn is_empty(&self) -> bool

Whether the artifact contains no crates.

Source

pub fn get(&self, name: &str) -> Option<Entry<'_>>

Name lookup, folded: case-insensitive, and - and _ are the same character. get("Tokio_Util") finds tokio-util, because crates.io would not have let a second crate claim that name.

Source

pub fn entry_at(&self, index: usize) -> Option<Entry<'_>>

The entry at line index (0-based, in the artifact’s folded-name sort order), or None if out of range. Paired with len this is the stable handle a caller needs to build a side index that refers back into the artifact by position rather than copying names.

Source

pub fn prefix_indices(&self, prefix: &str) -> Range<usize>

The half-open range of line indices whose folded name starts with prefix (folded as in get) — the same range count measures, exposed as positions so a caller can pair whole-name-prefix hits with entry_at.

Source

pub fn count(&self, prefix: &str) -> usize

How many crate names start with prefix, folded as in get. Two binary searches — no enumeration — so this is as cheap for "s" as for "trillium-".

Source

pub fn prefix(&self, prefix: &str) -> impl Iterator<Item = Entry<'_>>

All crates whose name starts with prefix, folded as in get, in artifact order.

Source

pub fn typeahead(&self, prefix: &str, limit: usize) -> Vec<Entry<'_>>

The limit highest-ranked crates whose name starts with prefix (folded as in get), ties broken by name.

Trait Implementations§

Source§

impl Debug for CrateNames

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.