rust

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package rust provides dependency resolution for Rust crates.

Overview

This package implements deps.Language for Rust, supporting:

  • crates.io registry resolution via crates client
  • Cargo.toml manifest parsing

Registry Resolution

Use [Language.Resolver] to fetch dependencies from crates.io:

resolver, _ := rust.Language.Resolver()
g, _ := resolver.Resolve(ctx, "serde", deps.Options{MaxDepth: 10})

Manifest Parsing

Parse Cargo.toml files:

parser, _ := rust.Language.Manifest("cargo", nil)
result, _ := parser.Parse("Cargo.toml", deps.Options{})

Note: Cargo.toml contains direct dependencies only. The resolver fetches transitive dependencies from crates.io.

crates: github.com/stacktower-io/stacktower/pkg/integrations/crates deps.Language: github.com/stacktower-io/stacktower/pkg/core/deps.Language

Index

Constants

This section is empty.

Variables

View Source
var Language = &deps.Language{
	Name:                  "rust",
	DefaultRegistry:       "crates",
	DefaultRuntimeVersion: "1.75",
	RegistryAliases:       map[string]string{"crates.io": "crates"},
	ManifestTypes:         []string{"cargo", "cargo-lock"},
	ManifestAliases: map[string]string{
		"Cargo.toml": "cargo",
		"cargo.toml": "cargo",
		"Cargo.lock": "cargo-lock",
		"cargo.lock": "cargo-lock",
	},
	NewResolver:     newResolver,
	NewManifest:     newManifest,
	ManifestParsers: manifestParsers,
	NormalizeName: func(name string) string {
		return strings.ToLower(strings.TrimSpace(name))
	},
}

Language provides Rust dependency resolution via crates.io. Supports Cargo.toml and Cargo.lock manifest files.

Functions

This section is empty.

Types

type CargoLock

type CargoLock struct{}

CargoLock parses Cargo.lock files. It provides a full transitive closure of the dependency graph without needing to contact a registry.

func (*CargoLock) IncludesTransitive

func (c *CargoLock) IncludesTransitive() bool

func (*CargoLock) Parse

func (c *CargoLock) Parse(path string, opts deps.Options) (*deps.ManifestResult, error)

func (*CargoLock) Supports

func (c *CargoLock) Supports(name string) bool

func (*CargoLock) Type

func (c *CargoLock) Type() string

type CargoMatcher

type CargoMatcher struct{}

CargoMatcher implements constraint matching for Cargo's semver specifiers. Cargo uses semver with caret as the default operator. Supports: ^, ~, >=, <=, >, <, =, *, and comma-separated ranges.

func (CargoMatcher) ParseConstraint

func (CargoMatcher) ParseConstraint(constraint string) pubgrub.Condition

ParseConstraint converts a Cargo version requirement to a PubGrub Condition. Cargo requirements: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html

func (CargoMatcher) ParseVersion

func (CargoMatcher) ParseVersion(version string) pubgrub.Version

ParseVersion converts a Cargo version string to a PubGrub SemanticVersion.

type CargoToml

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

CargoToml parses Cargo.toml files. It extracts direct, dev, and build dependencies.

func (*CargoToml) IncludesTransitive

func (c *CargoToml) IncludesTransitive() bool

func (*CargoToml) Parse

func (c *CargoToml) Parse(path string, opts deps.Options) (*deps.ManifestResult, error)

func (*CargoToml) Supports

func (c *CargoToml) Supports(name string) bool

func (*CargoToml) Type

func (c *CargoToml) Type() string

Jump to

Keyboard shortcuts

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