cargo

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cargo validates crates and supplies Cargo sparse-index records.

Index

Constants

View Source
const (
	MaxCrate = 64 << 20

	MaxIndex       = 16 << 20
	RecordProperty = "cargo.index"
	YankedProperty = "cargo.yanked"
)

Variables

View Source
var (
	ErrInvalid = errors.New("cargo: invalid cargo crate")
)

Functions

func CratePath

func CratePath(name, version string) string

func Encode

func Encode(r Record) (string, error)

func IndexPath

func IndexPath(name string) string

func Inspect

func Inspect(ctx context.Context, body io.Reader, size int64, p string) (string, string, error)

Inspect validates the complete bounded .crate gzip tarball. Every entry must be a unique path under the archive root, and the manifest identity must match the canonical item path.

func ParseCratePath

func ParseCratePath(p string) (name, version string, ok bool)

func Serves

func Serves(t repo.PackageType) bool

func ValidName

func ValidName(s string) bool

func ValidVersion

func ValidVersion(s string) bool

Types

type Dependency

type Dependency struct {
	Name            string   `json:"name"`
	Req             string   `json:"req"`
	Features        []string `json:"features"`
	Optional        bool     `json:"optional"`
	DefaultFeatures bool     `json:"default_features"`
	Target          *string  `json:"target"`
	Kind            string   `json:"kind"`
	Registry        *string  `json:"registry"`
	Package         *string  `json:"package"`
}

type Handler

type Handler struct{ generic.Handler }

func (Handler) Admit

func (Handler) Admit(
	ctx context.Context,
	env format.Env,
	c repo.Config,
	w format.Write,
) (format.Write, error)

func (Handler) Deployed

func (Handler) Deployed(ctx context.Context, env format.Env, _ repo.Config, it types.Item) error

func (Handler) Inspect

func (Handler) Inspect(
	ctx context.Context,
	env format.Env,
	_ repo.Config,
	w format.Write,
) (any, error)

func (Handler) Reindex

func (Handler) Reindex(ctx context.Context, env format.Env, c repo.Config) error

type Record

type Record struct {
	Name        string              `json:"name"`
	Version     string              `json:"vers"`
	Deps        []Dependency        `json:"deps"`
	Checksum    string              `json:"cksum"`
	Features    map[string][]string `json:"features"`
	Yanked      bool                `json:"yanked"`
	Links       *string             `json:"links,omitempty"`
	RustVersion *string             `json:"rust_version,omitempty"`
}

func (Record) IsValid

func (r Record) IsValid() bool

Jump to

Keyboard shortcuts

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