rust

package
v0.7.5 Latest Latest
Warning

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

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

Documentation

Overview

Package rust implements omnibump support for Rust projects. Ported from cargobump with enhancements for the unified omnibump architecture.

Package rust implements omnibump support for Rust projects. Ported from cargobump with enhancements for the unified omnibump architecture.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidCrateName is returned when a crate name is invalid.
	ErrInvalidCrateName = errors.New("invalid crate name")

	// ErrInvalidVersion is returned when a version string is invalid.
	ErrInvalidVersion = errors.New("invalid version string")
)
View Source
var (
	// ErrCargoLockNotFound is returned when Cargo.lock is not found.
	ErrCargoLockNotFound = errors.New("cargo.lock not found")

	// ErrRemoteAnalysisNotImplemented is returned when remote analysis is not implemented.
	ErrRemoteAnalysisNotImplemented = errors.New("remote analysis not yet implemented")
)
View Source
var ErrInvalidPackageSpec = errors.New("invalid package spec")

ErrInvalidPackageSpec is returned when a package spec is missing required fields.

Functions

func CargoUpdate

func CargoUpdate(ctx context.Context, cargoRoot string) (string, error)

CargoUpdate runs 'cargo update' to refresh the Cargo.lock file. Ported from cargobump/pkg/run/cargo.go.

func CargoUpdatePackage

func CargoUpdatePackage(ctx context.Context, name, oldVersion, newVersion, cargoRoot string) (string, error)

CargoUpdatePackage updates a specific package to a precise version. Uses: cargo update --precise <newVersion> --package <name>@<oldVersion> Ported from cargobump/pkg/run/cargo.go.

func DoUpdate

func DoUpdate(ctx context.Context, packages map[string]*Package, cargoPackages []CargoPackage, cfg *UpdateConfig) error

DoUpdate performs the actual update of Rust package dependencies. Ported from cargobump/pkg/update.go.

func ParseBumpFile

func ParseBumpFile(r io.Reader) (map[string]*Package, error)

ParseBumpFile parses a YAML file containing package update specifications. Ported from cargobump/pkg/parser/parser.go:ParseBumpFile.

Types

type CargoPackage

type CargoPackage struct {
	Name         string
	Version      string
	Source       string
	Dependencies []string
}

CargoPackage represents a package from Cargo.lock.

func ParseCargoLock

func ParseCargoLock(r io.Reader) ([]CargoPackage, error)

ParseCargoLock parses a Cargo.lock file and returns the list of packages.

type Lockfile

type Lockfile struct {
	Packages []cargoLockPackage `toml:"package"`
}

Lockfile represents a Cargo.lock file structure. Based on https://doc.rust-lang.org/cargo/reference/manifest.html

type Package

type Package struct {
	Name    string
	Version string
	Index   int // For ordering updates
}

Package represents a Cargo package dependency.

type PackageList

type PackageList struct {
	Packages []Package `json:"packages" yaml:"packages"`
}

PackageList is used to marshal from yaml/json file to get the list of packages.

type Rust

type Rust struct{}

Rust implements the Language interface for Rust projects.

func (*Rust) Detect

func (r *Rust) Detect(ctx context.Context, dir string) (bool, error)

Detect checks if Rust manifest files exist in the directory.

func (*Rust) GetManifestFiles

func (r *Rust) GetManifestFiles() []string

GetManifestFiles returns Rust manifest files.

func (*Rust) Name

func (r *Rust) Name() string

Name returns the language identifier.

func (*Rust) SupportsAnalysis

func (r *Rust) SupportsAnalysis() bool

SupportsAnalysis returns true since Rust now has analysis capabilities.

func (*Rust) Update

func (r *Rust) Update(ctx context.Context, cfg *languages.UpdateConfig) error

Update performs dependency updates on a Rust project.

func (*Rust) Validate

func (r *Rust) Validate(ctx context.Context, cfg *languages.UpdateConfig) error

Validate checks if the updates were applied successfully.

type RustAnalyzer

type RustAnalyzer struct{}

RustAnalyzer implements the Analyzer interface for Rust projects.

func (*RustAnalyzer) Analyze

func (ra *RustAnalyzer) Analyze(ctx context.Context, projectPath string) (*analyzer.AnalysisResult, error)

Analyze performs dependency analysis on a Rust project.

func (*RustAnalyzer) AnalyzeRemote

func (ra *RustAnalyzer) AnalyzeRemote(ctx context.Context, files map[string][]byte) (*analyzer.RemoteAnalysisResult, error)

AnalyzeRemote performs dependency analysis on remotely-fetched Rust files. Not yet implemented for Rust - returns error. TODO: Implement this function and use ctx for logging and files for analysis.

func (*RustAnalyzer) RecommendStrategy

func (ra *RustAnalyzer) RecommendStrategy(ctx context.Context, analysis *analyzer.AnalysisResult, deps []analyzer.Dependency) (*analyzer.Strategy, error)

RecommendStrategy suggests update strategy for Rust dependencies. For Rust, updates are always direct using cargo update.

type UpdateConfig

type UpdateConfig struct {
	CargoRoot string
	Update    bool // Run 'cargo update' before updating packages
	ShowDiff  bool
}

UpdateConfig holds configuration for Rust project updates.

Jump to

Keyboard shortcuts

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