Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate codegen to pure-rust generator #8

Merged
merged 3 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "dat-network-protocol"
description = "Dat Network Protocol protobuf definitions."
version = "0.1.4"
version = "0.2.0"
authors = ["Yoshua Wuyts <[email protected]>"]
license = "MIT OR Apache-2.0"
readme = "README.md"

[dependencies]
protobuf = "2.0.4"
protobuf = "=2.10.1"

[build-dependencies]
protoc-rust = "2.0.4"
protobuf-codegen-pure = "=2.10.1"
8 changes: 2 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// extern crate protoc_rust;

// use protoc_rust::Customize;

// Uncomment method below for like local builds.
fn main() -> Result<(), Box<dyn std::error::Error>> {
// protoc_rust::run(protoc_rust::Args {
// protobuf_codegen_pure::run(protobuf_codegen_pure::Args {
// out_dir: "src",
// input: &[
// "protos/cancel.proto",
Expand All @@ -19,7 +15,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// "protos/unwant.proto",
// "protos/want.proto",
// ],
// customize: Customize {
// customize: protobuf_codegen_pure::Customize {
// ..Default::default()
// },
// includes: &["protos"],
Expand Down
73 changes: 42 additions & 31 deletions src/cancel.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// This file is generated by rust-protobuf 2.0.4. Do not edit
// This file is generated by rust-protobuf 2.10.1. Do not edit
// @generated

// https://github.com/Manishearth/rust-clippy/issues/702
// https://github.com/rust-lang/rust-clippy/issues/702
#![allow(unknown_lints)]
#![allow(clippy)]
#![allow(clippy::all)]

#![cfg_attr(rustfmt, rustfmt_skip)]

Expand All @@ -17,19 +17,30 @@
#![allow(unsafe_code)]
#![allow(unused_imports)]
#![allow(unused_results)]
//! Generated file from `cancel.proto`

use protobuf::Message as Message_imported_for_functions;
use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions;

/// Generated files are compatible only with the same version
/// of protobuf runtime.
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_10_1;

#[derive(PartialEq,Clone,Default)]
pub struct Cancel {
// message fields
index: ::std::option::Option<u64>,
bytes: ::std::option::Option<u64>,
hash: ::std::option::Option<bool>,
// special fields
unknown_fields: ::protobuf::UnknownFields,
cached_size: ::protobuf::CachedSize,
pub unknown_fields: ::protobuf::UnknownFields,
pub cached_size: ::protobuf::CachedSize,
}

impl<'a> ::std::default::Default for &'a Cancel {
fn default() -> &'a Cancel {
<Cancel as ::protobuf::Message>::default_instance()
}
}

impl Cancel {
Expand All @@ -39,6 +50,10 @@ impl Cancel {

// required uint64 index = 1;


pub fn get_index(&self) -> u64 {
self.index.unwrap_or(0)
}
pub fn clear_index(&mut self) {
self.index = ::std::option::Option::None;
}
Expand All @@ -52,12 +67,12 @@ impl Cancel {
self.index = ::std::option::Option::Some(v);
}

pub fn get_index(&self) -> u64 {
self.index.unwrap_or(0)
}

// optional uint64 bytes = 2;


pub fn get_bytes(&self) -> u64 {
self.bytes.unwrap_or(0)
}
pub fn clear_bytes(&mut self) {
self.bytes = ::std::option::Option::None;
}
Expand All @@ -71,12 +86,12 @@ impl Cancel {
self.bytes = ::std::option::Option::Some(v);
}

pub fn get_bytes(&self) -> u64 {
self.bytes.unwrap_or(0)
}

// optional bool hash = 3;


pub fn get_hash(&self) -> bool {
self.hash.unwrap_or(false)
}
pub fn clear_hash(&mut self) {
self.hash = ::std::option::Option::None;
}
Expand All @@ -89,10 +104,6 @@ impl Cancel {
pub fn set_hash(&mut self, v: bool) {
self.hash = ::std::option::Option::Some(v);
}

pub fn get_hash(&self) -> bool {
self.hash.unwrap_or(false)
}
}

impl ::protobuf::Message for Cancel {
Expand All @@ -103,7 +114,7 @@ impl ::protobuf::Message for Cancel {
true
}

fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> {
fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> {
while !is.eof()? {
let (field_number, wire_type) = is.read_tag_unpack()?;
match field_number {
Expand Down Expand Up @@ -154,7 +165,7 @@ impl ::protobuf::Message for Cancel {
my_size
}

fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> {
fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> {
if let Some(v) = self.index {
os.write_uint64(1, v)?;
}
Expand All @@ -180,13 +191,13 @@ impl ::protobuf::Message for Cancel {
&mut self.unknown_fields
}

fn as_any(&self) -> &::std::any::Any {
self as &::std::any::Any
fn as_any(&self) -> &dyn (::std::any::Any) {
self as &dyn (::std::any::Any)
}
fn as_any_mut(&mut self) -> &mut ::std::any::Any {
self as &mut ::std::any::Any
fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) {
self as &mut dyn (::std::any::Any)
}
fn into_any(self: Box<Self>) -> ::std::boxed::Box<::std::any::Any> {
fn into_any(self: Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run cargo fmt on the files? With edition=2018 the ::prefix on paths should have been removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't run anything, just the generation steps from the lib. I could take a look on that later on and try to fix the CI as well

self
}

Expand Down Expand Up @@ -243,15 +254,15 @@ impl ::protobuf::Message for Cancel {

impl ::protobuf::Clear for Cancel {
fn clear(&mut self) {
self.clear_index();
self.clear_bytes();
self.clear_hash();
self.index = ::std::option::Option::None;
self.bytes = ::std::option::Option::None;
self.hash = ::std::option::Option::None;
self.unknown_fields.clear();
}
}

impl ::std::fmt::Debug for Cancel {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::protobuf::text_format::fmt(self, f)
}
}
Expand All @@ -263,9 +274,9 @@ impl ::protobuf::reflect::ProtobufValue for Cancel {
}

static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0ccancel.proto\"H\n\x06Cancel\x12\x14\n\x05index\x18\x01\x20\x02(\
\x04R\x05index\x12\x14\n\x05bytes\x18\x02\x20\x01(\x04R\x05bytes\x12\x12\
\n\x04hash\x18\x03\x20\x01(\x08R\x04hash\
\n\x0ccancel.proto\x12\0\"<\n\x06Cancel\x12\x0f\n\x05index\x18\x01\x20\
\x02(\x04B\0\x12\x0f\n\x05bytes\x18\x02\x20\x01(\x04B\0\x12\x0e\n\x04has\
h\x18\x03\x20\x01(\x08B\0:\0B\0b\x06proto2\
";

static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy {
Expand Down
Loading