Skip to content

Commit 2648cd4

Browse files
GearsDatapackslpil
authored andcommitted
Add generated proto files to src
1 parent 37a38a4 commit 2648cd4

File tree

5 files changed

+154
-20
lines changed

5 files changed

+154
-20
lines changed

build.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
/// `prost_build` generates files in the output directory, which means that if we want
2+
/// to use it, we would need the protoc compiler as a build dependency.
3+
/// To get around this, we need run the build script and manually copy the generated files
4+
/// into the `src` folder. To do so, uncomment the below lines, then copy the files from the
5+
/// output directory into the `src/proto` folder. The path to the output directory
6+
/// will be printed in the terminal.
7+
///
18
fn main() {
2-
prost_build::compile_protos(
3-
&[
4-
"proto/signed.proto",
5-
"proto/package.proto",
6-
"proto/versions.proto",
7-
],
8-
&["proto/"],
9-
)
10-
.expect("Failed to generate prost code from .proto files.");
9+
// prost_build::compile_protos(
10+
// &[
11+
// "proto/signed.proto",
12+
// "proto/package.proto",
13+
// "proto/versions.proto",
14+
// ],
15+
// &["proto/"],
16+
// )
17+
// .expect("Failed to generate prost code from .proto files");
18+
19+
// println!(
20+
// "cargo::warning=Regenerated proto files, which must be manually copied into the `src` directory. Generated files can be found in {}",
21+
// std::env::var("OUT_DIR").unwrap_or_default()
22+
// );
1123
}

src/proto.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
#![allow(clippy::enum_variant_names)]
22

3-
pub mod package {
4-
include!(concat!(env!("OUT_DIR"), "/package.rs"));
5-
}
6-
7-
pub mod signed {
8-
include!(concat!(env!("OUT_DIR"), "/signed.rs"));
9-
}
10-
11-
pub mod versions {
12-
include!(concat!(env!("OUT_DIR"), "/versions.rs"));
13-
}
3+
pub mod package;
4+
pub mod signed;
5+
pub mod versions;

src/proto/package.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// This file is @generated by prost-build.
2+
#[derive(Clone, PartialEq, ::prost::Message)]
3+
pub struct Package {
4+
/// All releases of the package
5+
#[prost(message, repeated, tag = "1")]
6+
pub releases: ::prost::alloc::vec::Vec<Release>,
7+
/// Name of package
8+
#[prost(string, required, tag = "2")]
9+
pub name: ::prost::alloc::string::String,
10+
/// Name of repository
11+
#[prost(string, required, tag = "3")]
12+
pub repository: ::prost::alloc::string::String,
13+
}
14+
#[derive(Clone, PartialEq, ::prost::Message)]
15+
pub struct Release {
16+
/// Release version
17+
#[prost(string, required, tag = "1")]
18+
pub version: ::prost::alloc::string::String,
19+
/// sha256 checksum of "inner" package tarball
20+
/// deprecated in favor of outer_checksum
21+
#[prost(bytes = "vec", required, tag = "2")]
22+
pub inner_checksum: ::prost::alloc::vec::Vec<u8>,
23+
/// All dependencies of the release
24+
#[prost(message, repeated, tag = "3")]
25+
pub dependencies: ::prost::alloc::vec::Vec<Dependency>,
26+
/// If set the release is retired, a retired release should only be
27+
/// resolved if it has already been locked in a project
28+
#[prost(message, optional, tag = "4")]
29+
pub retired: ::core::option::Option<RetirementStatus>,
30+
/// sha256 checksum of outer package tarball
31+
/// required when encoding but optional when decoding
32+
#[prost(bytes = "vec", optional, tag = "5")]
33+
pub outer_checksum: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
34+
}
35+
#[derive(Clone, PartialEq, ::prost::Message)]
36+
pub struct RetirementStatus {
37+
#[prost(enumeration = "RetirementReason", required, tag = "1")]
38+
pub reason: i32,
39+
#[prost(string, optional, tag = "2")]
40+
pub message: ::core::option::Option<::prost::alloc::string::String>,
41+
}
42+
#[derive(Clone, PartialEq, ::prost::Message)]
43+
pub struct Dependency {
44+
/// Package name of dependency
45+
#[prost(string, required, tag = "1")]
46+
pub package: ::prost::alloc::string::String,
47+
/// Version requirement of dependency
48+
#[prost(string, required, tag = "2")]
49+
pub requirement: ::prost::alloc::string::String,
50+
/// If set and true the package is optional (see dependency resolution)
51+
#[prost(bool, optional, tag = "3")]
52+
pub optional: ::core::option::Option<bool>,
53+
/// If set is the OTP application name of the dependency, if not set the
54+
/// application name is the same as the package name
55+
#[prost(string, optional, tag = "4")]
56+
pub app: ::core::option::Option<::prost::alloc::string::String>,
57+
/// If set, the repository where the dependency is located
58+
#[prost(string, optional, tag = "5")]
59+
pub repository: ::core::option::Option<::prost::alloc::string::String>,
60+
}
61+
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
62+
#[repr(i32)]
63+
pub enum RetirementReason {
64+
RetiredOther = 0,
65+
RetiredInvalid = 1,
66+
RetiredSecurity = 2,
67+
RetiredDeprecated = 3,
68+
RetiredRenamed = 4,
69+
}
70+
impl RetirementReason {
71+
/// String value of the enum field names used in the ProtoBuf definition.
72+
///
73+
/// The values are not transformed in any way and thus are considered stable
74+
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
75+
pub fn as_str_name(&self) -> &'static str {
76+
match self {
77+
Self::RetiredOther => "RETIRED_OTHER",
78+
Self::RetiredInvalid => "RETIRED_INVALID",
79+
Self::RetiredSecurity => "RETIRED_SECURITY",
80+
Self::RetiredDeprecated => "RETIRED_DEPRECATED",
81+
Self::RetiredRenamed => "RETIRED_RENAMED",
82+
}
83+
}
84+
/// Creates an enum from field names used in the ProtoBuf definition.
85+
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
86+
match value {
87+
"RETIRED_OTHER" => Some(Self::RetiredOther),
88+
"RETIRED_INVALID" => Some(Self::RetiredInvalid),
89+
"RETIRED_SECURITY" => Some(Self::RetiredSecurity),
90+
"RETIRED_DEPRECATED" => Some(Self::RetiredDeprecated),
91+
"RETIRED_RENAMED" => Some(Self::RetiredRenamed),
92+
_ => None,
93+
}
94+
}
95+
}

src/proto/signed.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This file is @generated by prost-build.
2+
#[derive(Clone, PartialEq, ::prost::Message)]
3+
pub struct Signed {
4+
/// Signed contents
5+
#[prost(bytes = "vec", required, tag = "1")]
6+
pub payload: ::prost::alloc::vec::Vec<u8>,
7+
/// The signature
8+
#[prost(bytes = "vec", optional, tag = "2")]
9+
pub signature: ::core::option::Option<::prost::alloc::vec::Vec<u8>>,
10+
}

src/proto/versions.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// This file is @generated by prost-build.
2+
#[derive(Clone, PartialEq, ::prost::Message)]
3+
pub struct Versions {
4+
/// All packages in the repository
5+
#[prost(message, repeated, tag = "1")]
6+
pub packages: ::prost::alloc::vec::Vec<VersionsPackage>,
7+
/// Name of repository
8+
#[prost(string, required, tag = "2")]
9+
pub repository: ::prost::alloc::string::String,
10+
}
11+
#[derive(Clone, PartialEq, ::prost::Message)]
12+
pub struct VersionsPackage {
13+
/// Package name
14+
#[prost(string, required, tag = "1")]
15+
pub name: ::prost::alloc::string::String,
16+
/// All released versions of the package
17+
#[prost(string, repeated, tag = "2")]
18+
pub versions: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
19+
/// Zero-based indexes of retired versions in the versions field, see package.proto
20+
///
21+
/// If set, the name of the package repository (NEVER USED, DEPRECATED)
22+
/// string repository = 4;
23+
#[prost(int32, repeated, tag = "3")]
24+
pub retired: ::prost::alloc::vec::Vec<i32>,
25+
}

0 commit comments

Comments
 (0)