cratesio

package
v0.0.0-...-0effba1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package cratesio simplifies calling the Crates.io API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Download

func Download(ctx context.Context, crate *CrateVersion, dir string) error

Download fetches the given Rust crate version and writes the contents into the directory dir.

Types

type Crate

type Crate struct {
	Categories []*CrateCategory `json:"categories"`
	Crate      CrateData        `json:"crate"`
	Keywords   []*CrateKeyword  `json:"keywords"`
	Versions   []*CrateVersion  `json:"versions"`
}

Crate contains the metadata for a Rust Crate, as provided by the crates.io API.

func Lookup

func Lookup(ctx context.Context, crate string) (*Crate, error)

Lookup returns the metadata for a Rust crate using the crates.io API.

type CrateCategory

type CrateCategory struct {
	Category    string    `json:"category"`
	CratesCount uint64    `json:"crates_cnt"`
	CreatedAt   time.Time `json:"created_at"`
	Description string    `json:"description"`
	Id          string    `json:"id"`
	Slug        string    `json:"slug"`
}

CrateCategory includes information about a category of Rust crates, as provided by the crates.io API.

type CrateData

type CrateData struct {
	Id              string     `json:"id"`
	Name            string     `json:"name"`
	Description     string     `json:"description,omitempty"`
	License         string     `json:"license,omitempty"`
	Documentation   string     `json:"documentation,omitempty"`
	Homepage        string     `json:"homepage,omitempty"`
	Repository      string     `json:"repository,omitempty"`
	Downloads       uint64     `json:"downloads"`
	RecentDownloads uint64     `json:"recent_downloads,omitempty"`
	Categories      []string   `json:"categories,omitempty"`
	Keywords        []string   `json:"keywords,omitempty"`
	Versions        []uint64   `json:"versions,omitempty"`
	MaxVersion      string     `json:"max_version"`
	Links           CrateLinks `json:"links"`
	CreatedAt       time.Time  `json:"created_at"`
	UpdatedAt       time.Time  `json:"updated_at"`
	ExactMatch      bool       `json:"exact_match"`
}

CrateData includes the metadata about a Rust crate, as provided by the crates.io API.

type CrateKeyword

type CrateKeyword struct {
	Id          string    `json:"id"`
	Keyword     string    `json:"keyword"`
	CratesCount uint64    `json:"crates_cnt"`
	CreatedAt   time.Time `json:"created_at"`
}

CrateKeyword includes information about a keyword that describes a set of Rust crates, as provided by the crates.io API.

type CrateLinks struct {
	OwnerTeam           string   `json:"owner_team"`
	OwnerUser           string   `json:"owner_user"`
	Owners              string   `json:"owners"`
	ReverseDependencies string   `json:"reverse_dependencies"`
	VersionDownloads    string   `json:"version_downloads"`
	Versions            []string `json:"versions,omitempty"`
}

CrateLinks includes the standard set of hyperlinks for a Rust crate, as provided by the crates.io API.

type CrateUser

type CrateUser struct {
	Avatar string `json:"avatar,omitempty"`
	Email  string `json:"email,omitempty"`
	Id     uint64 `json:"id"`
	Kind   string `json:"kind,omitempty"`
	Login  string `json:"login"`
	Name   string `json:"name,omitempty"`
	URL    string `json:"url"`
}

CrateUser includes the metadata about a user of crates.io, as provided by the API.

type CrateVersion

type CrateVersion struct {
	Crate        string              `json:"crate"`
	CreatedAt    time.Time           `json:"created_at"`
	UpdatedAt    time.Time           `json:"updated_at"`
	DownloadPath string              `json:"dl_path"`
	Downloads    uint64              `json:"downloads"`
	Features     map[string][]string `json:"features"`
	Id           uint64              `json:"id"`
	Number       string              `json:"num"`
	Yanked       bool                `json:"yanked"`
	License      string              `json:"license,omitempty"`
	ReadmePath   string              `json:"readme_path,omitempty"`
	Links        CrateVersionLinks   `json:"links"`
	CrateSize    uint64              `json:"crate_size,omitempty"`
	PublishedBy  *CrateUser          `json:"published_by,omitempty"`
}

CrateVersion includes information about a published version of a Rust crate, as provided by the crates.io API.

type CrateVersionLinks struct {
	Dependencies     string `json:"dependencies"`
	VersionDownloads string `json:"version_downloads"`
}

CrateVersionLinks includes the standard set of hyperlinks for a published version of a Rust crate, as provided by the crates.io API.

Jump to

Keyboard shortcuts

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