mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-13 01:51:23 +00:00
protocols/plaintext: Adapt protobuf generation to consolidated scripts (#1309)
* protocols/plaintext: Adapt protobuf generation to consolidated scripts * protocols/plaintext: Fix protobuf import Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
This commit is contained in:
committed by
Pierre Krieger
parent
324f0dc326
commit
b939aefdd6
@ -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::*;
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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;
|
6
protocols/plaintext/src/structs.proto
Normal file
6
protocols/plaintext/src/structs.proto
Normal file
@ -0,0 +1,6 @@
|
||||
syntax = "proto2";
|
||||
|
||||
message Exchange {
|
||||
optional bytes id = 1;
|
||||
optional bytes pubkey = 2;
|
||||
}
|
@ -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 {
|
||||
<Exchange as ::protobuf::Message>::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<u8> {
|
||||
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<Self>) -> ::std::boxed::Box<::std::any::Any> {
|
||||
fn into_any(self: Box<Self>) -> ::std::boxed::Box<dyn (::std::any::Any)> {
|
||||
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 {
|
Reference in New Issue
Block a user