diff --git a/protocols/plaintext/regen_structs_proto.sh b/protocols/plaintext/regen_structs_proto.sh index 9ac7ab8f..42ecc3ec 100755 --- a/protocols/plaintext/regen_structs_proto.sh +++ b/protocols/plaintext/regen_structs_proto.sh @@ -1,8 +1,4 @@ #!/bin/sh -docker run --rm -v "`pwd`/../../":/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.3.0 protobuf-codegen; \ - protoc --rust_out=./protocols/plaintext/src/pb ./protocols/plaintext/structs.proto;" +../../scripts/protobuf/gen.sh ./src/structs.proto diff --git a/protocols/plaintext/src/handshake.rs b/protocols/plaintext/src/handshake.rs index b3c6ca4b..c0b02acc 100644 --- a/protocols/plaintext/src/handshake.rs +++ b/protocols/plaintext/src/handshake.rs @@ -20,7 +20,7 @@ use crate::PlainText2Config; use crate::error::PlainTextError; -use crate::pb::structs::Exchange; +use crate::structs_proto::Exchange; use bytes::BytesMut; use futures::prelude::*; diff --git a/protocols/plaintext/src/lib.rs b/protocols/plaintext/src/lib.rs index 985ff0e3..e57139eb 100644 --- a/protocols/plaintext/src/lib.rs +++ b/protocols/plaintext/src/lib.rs @@ -43,7 +43,7 @@ use void::Void; mod error; mod handshake; -mod pb; +mod structs_proto; /// `PlainText1Config` is an insecure connection handshake for testing purposes only. /// diff --git a/protocols/plaintext/src/pb.rs b/protocols/plaintext/src/pb.rs deleted file mode 100644 index 64e83e5d..00000000 --- a/protocols/plaintext/src/pb.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2019 Parity Technologies (UK) Ltd. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -pub mod structs; diff --git a/protocols/plaintext/structs.proto b/protocols/plaintext/src/structs.proto similarity index 100% rename from protocols/plaintext/structs.proto rename to protocols/plaintext/src/structs.proto diff --git a/protocols/plaintext/src/pb/structs.rs b/protocols/plaintext/src/structs_proto.rs similarity index 81% rename from protocols/plaintext/src/pb/structs.rs rename to protocols/plaintext/src/structs_proto.rs index 85da2b49..4063daea 100644 --- a/protocols/plaintext/src/pb/structs.rs +++ b/protocols/plaintext/src/structs_proto.rs @@ -1,9 +1,9 @@ -// This file is generated by rust-protobuf 2.3.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/structs.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_8_1; + #[derive(PartialEq,Clone,Default)] pub struct Exchange { // message fields @@ -31,6 +36,12 @@ pub struct Exchange { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a Exchange { + fn default() -> &'a Exchange { + ::default_instance() + } +} + impl Exchange { pub fn new() -> Exchange { ::std::default::Default::default() @@ -38,6 +49,13 @@ impl Exchange { // optional bytes id = 1; + + pub fn get_id(&self) -> &[u8] { + match self.id.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_id(&mut self) { self.id.clear(); } @@ -65,15 +83,15 @@ impl Exchange { self.id.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_id(&self) -> &[u8] { - match self.id.as_ref() { + // optional bytes pubkey = 2; + + + pub fn get_pubkey(&self) -> &[u8] { + match self.pubkey.as_ref() { Some(v) => &v, None => &[], } } - - // optional bytes pubkey = 2; - pub fn clear_pubkey(&mut self) { self.pubkey.clear(); } @@ -100,13 +118,6 @@ impl Exchange { pub fn take_pubkey(&mut self) -> ::std::vec::Vec { self.pubkey.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - - pub fn get_pubkey(&self) -> &[u8] { - match self.pubkey.as_ref() { - Some(v) => &v, - None => &[], - } - } } impl ::protobuf::Message for Exchange { @@ -114,7 +125,7 @@ impl ::protobuf::Message for Exchange { 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 { @@ -147,7 +158,7 @@ impl ::protobuf::Message for Exchange { 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(ref v) = self.id.as_ref() { os.write_bytes(1, &v)?; } @@ -170,13 +181,13 @@ impl ::protobuf::Message for Exchange { &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) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } @@ -228,14 +239,14 @@ impl ::protobuf::Message for Exchange { impl ::protobuf::Clear for Exchange { fn clear(&mut self) { - self.clear_id(); - self.clear_pubkey(); + self.id.clear(); + self.pubkey.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Exchange { - 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) } } @@ -247,17 +258,17 @@ impl ::protobuf::reflect::ProtobufValue for Exchange { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n!protocols/plaintext/structs.proto\"2\n\x08Exchange\x12\x0e\n\x02id\ - \x18\x01\x20\x01(\x0cR\x02id\x12\x16\n\x06pubkey\x18\x02\x20\x01(\x0cR\ - \x06pubkeyJ\xb4\x01\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\ - \0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\ - \x02\x08\x10\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x02\x18\n\x0c\n\x05\x04\ - \0\x02\0\x04\x12\x03\x03\x02\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\ - \x0b\x10\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x11\x13\n\x0c\n\x05\x04\ - \0\x02\0\x03\x12\x03\x03\x16\x17\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\ - \x02\x1c\n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03\x04\x02\n\n\x0c\n\x05\x04\ - \0\x02\x01\x05\x12\x03\x04\x0b\x10\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\ - \x04\x11\x17\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x1a\x1b\ + \n\x11src/structs.proto\"2\n\x08Exchange\x12\x0e\n\x02id\x18\x01\x20\x01\ + (\x0cR\x02id\x12\x16\n\x06pubkey\x18\x02\x20\x01(\x0cR\x06pubkeyJ\xb4\ + \x01\n\x06\x12\x04\0\0\x05\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\ + \x04\0\x12\x04\x02\0\x05\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x10\n\ + \x0b\n\x04\x04\0\x02\0\x12\x03\x03\x02\x18\n\x0c\n\x05\x04\0\x02\0\x04\ + \x12\x03\x03\x02\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x0b\x10\n\x0c\ + \n\x05\x04\0\x02\0\x01\x12\x03\x03\x11\x13\n\x0c\n\x05\x04\0\x02\0\x03\ + \x12\x03\x03\x16\x17\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x02\x1c\n\x0c\ + \n\x05\x04\0\x02\x01\x04\x12\x03\x04\x02\n\n\x0c\n\x05\x04\0\x02\x01\x05\ + \x12\x03\x04\x0b\x10\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x04\x11\x17\n\ + \x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x1a\x1b\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy {