crates

package
v0.3.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package crates resolves Rust crate versions from the crates.io registry API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Provider)

Option configures a Provider.

func WithTransport

func WithTransport(rt http.RoundTripper) Option

WithTransport overrides the HTTP transport, for tests.

func WithVersion

func WithVersion(version string) Option

WithVersion sets the clover version woven into the User-Agent. The composition root passes the running binary's version; an empty value keeps the versionless fallback.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider resolves Rust crate versions from the crates.io registry API. One fetch returns a crate's whole version history, so the provider lists candidates and lets the framework own selection, tagging each with the publish time and .crate checksum the API returns for free.

func New

func New(opts ...Option) *Provider

New returns the crates provider. The registry API is public and unauthenticated, so the client is a plain cached one with no ratelimit wrapper or credentials.

func (*Provider) Color

func (p *Provider) Color(dark bool) color.Color

Color is the provider's brand color. See provider.Provider.Color.

func (*Provider) Dated

func (p *Provider) Dated()

Dated marks the listing as date-bearing: every version carries its publish time, so cooldown applies.

func (*Provider) Describe

func (p *Provider) Describe(r provider.Resource) string

Describe returns a human-readable label for a resource.

func (*Provider) Discover

func (p *Provider) Discover(ctx context.Context, r provider.Resource) ([]model.Candidate, error)

Discover lists a crate's candidate versions, reading the registry API in one fetch. The API returns the whole version history in a single response, so there is no pagination and nothing is ever left unread - --deep has no work to do here. Candidates are sorted naturally for a deterministic listing.

func (*Provider) Identify

func (p *Provider) Identify(r provider.Resource) (string, string)

Identify returns the crate name and its crates.io page.

func (*Provider) Keys

func (p *Provider) Keys() []provider.Key

Keys reports the directive keys crates accepts, in canonical order.

func (*Provider) Name

func (p *Provider) Name() string

Name identifies the provider.

func (*Provider) Resource

func (p *Provider) Resource(d directive.Directive) (provider.Resource, error)

Resource validates a directive into a crates.io resource: the crate name, kept exactly as written because the registry looks crates up by their published spelling.

func (*Provider) URL

URL builds the crate page for a resolved candidate, versioned when the candidate carries a version. The path uses the candidate's Ref - the raw form the registry publishes - falling back to Version for a synthesized candidate with no ref.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL