cargometadata

package
v0.2.105 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cargometadata owns Codefly's typed boundary to Cargo's authoritative project graph. Consumers share one command and JSON contract instead of independently parsing Cargo.toml or inventing language metadata.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnavailable = errors.New("cargo is required")

ErrUnavailable reports that the real Cargo toolchain is absent.

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	Name   string  `json:"name"`
	Source *string `json:"source"`
	Req    string  `json:"req"`
	Kind   *string `json:"kind"`
	Rename *string `json:"rename"`
	Path   *string `json:"path"`
}

Dependency is a direct Cargo manifest dependency.

type DependencyKind

type DependencyKind struct {
	Kind *string `json:"kind"`
}

DependencyKind distinguishes normal, build, and development graph edges.

type Metadata

type Metadata struct {
	Packages         []Package `json:"packages"`
	Resolve          *Resolve  `json:"resolve"`
	WorkspaceMembers []string  `json:"workspace_members"`
	WorkspaceRoot    string    `json:"workspace_root"`
}

Metadata is Cargo metadata format-version 1 with the fields shared by project inspection and SBOM graph construction.

func Parse

func Parse(data []byte) (Metadata, error)

Parse decodes Cargo metadata format-version 1.

func Run

func Run(ctx context.Context, dir string, options Options) (Metadata, error)

Run executes Cargo's non-mutating metadata API and decodes its typed result.

type Node

type Node struct {
	ID   string           `json:"id"`
	Deps []NodeDependency `json:"deps"`
}

Node is one package in Cargo's resolved dependency graph.

type NodeDependency

type NodeDependency struct {
	Pkg      string           `json:"pkg"`
	DepKinds []DependencyKind `json:"dep_kinds"`
}

NodeDependency is one resolved package edge.

type Options

type Options struct {
	ManifestPath   string
	Locked         bool
	NoDependencies bool
	Offline        bool
}

Options controls read-only Cargo metadata collection.

type Package

type Package struct {
	Name         string       `json:"name"`
	Version      string       `json:"version"`
	ID           string       `json:"id"`
	Source       *string      `json:"source"`
	License      *string      `json:"license"`
	Checksum     *string      `json:"checksum"`
	ManifestPath string       `json:"manifest_path"`
	Edition      string       `json:"edition"`
	Dependencies []Dependency `json:"dependencies"`
	Targets      []Target     `json:"targets"`
}

Package is one Cargo package declaration.

type Resolve

type Resolve struct {
	Root  *string `json:"root"`
	Nodes []Node  `json:"nodes"`
}

Resolve is Cargo's resolved dependency graph.

type Target

type Target struct {
	Name    string   `json:"name"`
	Kind    []string `json:"kind"`
	SrcPath string   `json:"src_path"`
	Edition string   `json:"edition"`
}

Target is a Cargo package build target and its source entry point.

Jump to

Keyboard shortcuts

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