freighter_api_types/index/
request.rs

1use super::DependencyKind;
2use semver::{Version, VersionReq};
3#[cfg(feature = "server")]
4use serde::Deserialize;
5#[cfg(feature = "client")]
6use serde::Serialize;
7use std::collections::HashMap;
8
9#[cfg_attr(feature = "client", derive(Serialize))]
10#[cfg_attr(feature = "server", derive(Deserialize))]
11pub struct Publish {
12    /// The name of the package.
13    pub name: String,
14    /// The version of the package being published.
15    pub vers: Version,
16    /// Array of direct dependencies of the package.
17    pub deps: Vec<PublishDependency>,
18    /// Set of features defined for the package.
19    ///
20    /// Each feature maps to an array of features or dependencies it enables.
21    /// Cargo does not impose limitations on feature names, but crates.io requires alphanumeric
22    /// ASCII, `_` or `-` characters.
23    pub features: HashMap<String, Vec<String>>,
24    /// List of strings of the authors.
25    ///
26    /// May be empty.
27    #[cfg_attr(any(feature = "client", feature = "server"), serde(default))]
28    pub authors: Vec<String>,
29    /// Description field from the manifest.
30    ///
31    /// May be null. crates.io requires at least some content.
32    pub description: Option<String>,
33    /// String of the URL to the website for this package's documentation.
34    ///
35    /// May be null.
36    pub documentation: Option<String>,
37    /// String of the URL to the website for this package's home page.
38    ///
39    /// May be null.
40    pub homepage: Option<String>,
41    /// String of the content of the README file.
42    ///
43    /// May be null.
44    pub readme: Option<String>,
45    /// String of a relative path to a README file in the crate.
46    ///
47    /// May be null.
48    pub readme_file: Option<String>,
49    /// Array of strings of keywords for the package.
50    #[cfg_attr(any(feature = "client", feature = "server"), serde(default))]
51    pub keywords: Vec<String>,
52    /// Array of strings of categories for the package.
53    #[cfg_attr(any(feature = "client", feature = "server"), serde(default))]
54    pub categories: Vec<String>,
55    /// String of the license for the package.
56    ///
57    /// May be null. crates.io requires either `license` or `license_file` to be set.
58    pub license: Option<String>,
59    /// String of a relative path to a license file in the crate.
60    ///
61    /// May be null.
62    pub license_file: Option<String>,
63    /// String of the URL to the website for the source repository of this package.
64    ///
65    /// May be null.
66    pub repository: Option<String>,
67    /// Optional object of "status" badges.
68    ///
69    /// Each value is an object of arbitrary string to string mappings.
70    /// crates.io has special interpretation of the format of the badges.
71    pub badges: Option<HashMap<String, HashMap<String, String>>>,
72    /// The `links` string value from the package's manifest, or null if not specified.
73    ///
74    /// This field is optional and defaults to null.
75    pub links: Option<String>,
76}
77
78#[cfg_attr(feature = "client", derive(Serialize))]
79#[cfg_attr(feature = "server", derive(Deserialize))]
80pub struct PublishDependency {
81    /// Name of the dependency.
82    ///
83    /// If the dependency is renamed from the original package name, this is the original name.
84    /// The new package name is stored in the [`explicit_name_in_toml`] field.
85    pub name: String,
86    /// The semver requirement for this dependency.
87    pub version_req: VersionReq,
88    /// Array of features (as strings) enabled for this dependency.
89    pub features: Vec<String>,
90    /// Boolean of whether or not this is an optional dependency.
91    pub optional: bool,
92    /// Boolean of whether or not default features are enabled.
93    pub default_features: bool,
94    /// The target platform for the dependency.
95    ///
96    /// Null if not a target dependency. Otherwise, a string such as "cfg(windows)".
97    pub target: Option<String>,
98    /// The dependency kind.
99    ///
100    /// "dev", "build", or "normal".
101    pub kind: DependencyKind,
102    /// The URL of the index of the registry where this dependency is from as a string.
103    ///
104    /// If not specified or null, it is assumed the dependency is in the current registry.
105    pub registry: Option<String>,
106    /// If the dependency is renamed, this is a string of the new package name.
107    ///
108    /// If not specified or null, this dependency is not renamed.
109    pub explicit_name_in_toml: Option<String>,
110}
111
112#[cfg_attr(feature = "client", derive(Serialize))]
113#[cfg_attr(feature = "server", derive(Deserialize))]
114pub struct SearchQuery {
115    /// The search query string.
116    pub q: String,
117    /// Number of results, default 10, max 100.
118    pub per_page: Option<usize>,
119}
120
121/// Pagination information for certain operations.
122#[cfg_attr(feature = "client", derive(Serialize))]
123#[cfg_attr(feature = "server", derive(Deserialize))]
124pub struct ListQuery {
125    /// The number of crates to show in a given page.
126    pub per_page: Option<usize>,
127    /// The page to show.
128    pub page: Option<usize>,
129}