Documentation
¶
Overview ¶
Package rust provides Rust specific functionality for librarian.
Index ¶
- Variables
- func Add(lib *config.Library) *config.Library
- func Bump(ctx context.Context, library *config.Library, ...) error
- func DefaultLibraryName(api string) string
- func DefaultOutput(api, defaultOutput string) string
- func DeriveAPIPath(name string) string
- func Format(ctx context.Context, library *config.Library) error
- func Generate(ctx context.Context, cfg *config.Config, library *config.Library, ...) error
- func Install(ctx context.Context, tools *config.Tools) error
- func IsMixedLibrary(lib *config.Library) bool
- func Keep(library *config.Library) ([]string, error)
- func Publish(ctx context.Context, params PublishParams) error
- func ResolveDependencies(ctx context.Context, cfg *config.Config, lib *config.Library, ...) (*config.Config, error)
- func UpdateWorkspace(ctx context.Context) error
- type Cargo
- type CrateInfo
- type PublishParams
Constants ¶
This section is empty.
Variables ¶
var ErrMissingToolVersion = errors.New("cargo tool missing version")
ErrMissingToolVersion indicates a cargo tool entry is missing its version.
var ErrNoVersionField = errors.New("no version field found")
ErrNoVersionField indicates that the version field was not found in Cargo.toml.
Functions ¶
func Add ¶ added in v0.9.1
Add executes Rust-specific mutations of the given config.Library entry to be added to the librarian.yaml via `librarian add`.
Currently, it only sets the config.Library.Version property to the [defaultVersion] for Rust.
func Bump ¶ added in v0.8.1
func Bump(ctx context.Context, library *config.Library, output, version, gitExe, lastTag string) error
Bump checks if a version bump is required and performs it. It returns without error if no bump is needed (version already updated since lastTag).
func DefaultLibraryName ¶ added in v0.8.1
DefaultLibraryName derives a library name from an api path. For example: google/cloud/secretmanager/v1 -> google-cloud-secretmanager-v1.
func DefaultOutput ¶
DefaultOutput derives an output path from an api path and default output. For example: google/cloud/secretmanager/v1 with default src/generated/ returns src/generated/cloud/secretmanager/v1.
func DeriveAPIPath ¶ added in v0.8.1
DeriveAPIPath derives an api path from a library name. For example: google-cloud-secretmanager-v1 -> google/cloud/secretmanager/v1.
func Format ¶
Format formats a generated Rust library. Must be called sequentially; parallel calls cause race conditions as cargo fmt runs cargo metadata, which competes for locks on the workspace Cargo.toml and Cargo.lock.
func Generate ¶
func Generate(ctx context.Context, cfg *config.Config, library *config.Library, sources *sources.Sources) error
Generate generates a Rust client library.
func Install ¶ added in v0.10.0
Install installs cargo tool dependencies defined in the tools configuration.
func IsMixedLibrary ¶ added in v0.14.0
IsMixedLibrary reports whether the library has handwritten code wrapping generated code.
A library is a mixed library when it has Rust module configuration. A library with no APIs and an explicit output is a mixed library if its derived API path is not listed in sdk.yaml; libraries whose derived path appears in sdk.yaml are generated libraries whose APIs have not yet been populated (e.g. google-cloud-oslogin-common), not mixed libraries.
func Publish ¶
func Publish(ctx context.Context, params PublishParams) error
Publish finds all the crates that should be published. It can optionally run in dry-run mode, dry-run mode with continue on errors, and/or skip semver checks.
func ResolveDependencies ¶ added in v0.8.4
func ResolveDependencies(ctx context.Context, cfg *config.Config, lib *config.Library, sources *sources.Sources) (*config.Config, error)
ResolveDependencies automatically resolves Protobuf dependencies for a Rust library.
func UpdateWorkspace ¶ added in v0.8.1
UpdateWorkspace updates dependencies for the entire Rust workspace.
Types ¶
type Cargo ¶
type Cargo struct {
Package *CrateInfo `toml:"package"`
}
Cargo is a wrapper for CrateInfo for parsing Cargo.toml files.
type CrateInfo ¶
type CrateInfo struct {
Name string `toml:"name"`
Version string `toml:"version"`
Publish bool `toml:"publish"`
}
CrateInfo contains the package information.
type PublishParams ¶ added in v0.13.0
type PublishParams struct {
// Config is the repository configuration.
Config *config.Config
// DryRun indicates whether to run publish without actually pushing crates.
DryRun bool
// DryRunKeepGoing indicates whether to run in dry-run mode without stopping on errors.
DryRunKeepGoing bool
// SkipSemverChecks indicates whether to skip semantic versioning checks.
SkipSemverChecks bool
// Verbose indicates whether to stream the output of executed commands.
Verbose bool
// IgnoredChanges is a list of file paths/patterns to ignore when detecting changed crates.
IgnoredChanges []string
}
PublishParams holds parameters for running the Publish function.