mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-28 01:01:34 +00:00
*: Consolidate protobuf scripts and update to rust-protobuf 2.8.1 (#1275)
* *: Consolidate protobuf generation scripts * *: Update to rust-protobuf 2.8.1 * *: Mark protobuf generated modules with '_proto'
This commit is contained in:
committed by
Pierre Krieger
parent
b90aa37b95
commit
206e4e7553
@ -20,7 +20,7 @@
|
||||
|
||||
//! Noise protocol handshake I/O.
|
||||
|
||||
mod payload;
|
||||
mod payload_proto;
|
||||
|
||||
use crate::error::NoiseError;
|
||||
use crate::protocol::{Protocol, PublicKey, KeypairIdentity};
|
||||
@ -496,7 +496,7 @@ where
|
||||
},
|
||||
RecvIdentityState::ReadPayload(mut read_payload) => {
|
||||
if let Async::Ready((mut st, bytes)) = read_payload.poll()? {
|
||||
let pb: payload::Identity = protobuf::parse_from_bytes(&bytes)?;
|
||||
let pb: payload_proto::Identity = protobuf::parse_from_bytes(&bytes)?;
|
||||
if !pb.pubkey.is_empty() {
|
||||
let pk = identity::PublicKey::from_protobuf_encoding(pb.get_pubkey())
|
||||
.map_err(|_| NoiseError::InvalidKey)?;
|
||||
@ -551,7 +551,7 @@ where
|
||||
loop {
|
||||
match mem::replace(&mut self.state, SendIdentityState::Done) {
|
||||
SendIdentityState::Init(st) => {
|
||||
let mut pb = payload::Identity::new();
|
||||
let mut pb = payload_proto::Identity::new();
|
||||
if st.send_identity {
|
||||
pb.set_pubkey(st.identity.public.clone().into_protobuf_encoding());
|
||||
}
|
||||
|
@ -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/io/handshake/payload.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 Identity {
|
||||
// message fields
|
||||
@ -31,6 +36,12 @@ pub struct Identity {
|
||||
pub cached_size: ::protobuf::CachedSize,
|
||||
}
|
||||
|
||||
impl<'a> ::std::default::Default for &'a Identity {
|
||||
fn default() -> &'a Identity {
|
||||
<Identity as ::protobuf::Message>::default_instance()
|
||||
}
|
||||
}
|
||||
|
||||
impl Identity {
|
||||
pub fn new() -> Identity {
|
||||
::std::default::Default::default()
|
||||
@ -38,6 +49,10 @@ impl Identity {
|
||||
|
||||
// bytes pubkey = 1;
|
||||
|
||||
|
||||
pub fn get_pubkey(&self) -> &[u8] {
|
||||
&self.pubkey
|
||||
}
|
||||
pub fn clear_pubkey(&mut self) {
|
||||
self.pubkey.clear();
|
||||
}
|
||||
@ -58,12 +73,12 @@ impl Identity {
|
||||
::std::mem::replace(&mut self.pubkey, ::std::vec::Vec::new())
|
||||
}
|
||||
|
||||
pub fn get_pubkey(&self) -> &[u8] {
|
||||
&self.pubkey
|
||||
}
|
||||
|
||||
// bytes signature = 2;
|
||||
|
||||
|
||||
pub fn get_signature(&self) -> &[u8] {
|
||||
&self.signature
|
||||
}
|
||||
pub fn clear_signature(&mut self) {
|
||||
self.signature.clear();
|
||||
}
|
||||
@ -83,10 +98,6 @@ impl Identity {
|
||||
pub fn take_signature(&mut self) -> ::std::vec::Vec<u8> {
|
||||
::std::mem::replace(&mut self.signature, ::std::vec::Vec::new())
|
||||
}
|
||||
|
||||
pub fn get_signature(&self) -> &[u8] {
|
||||
&self.signature
|
||||
}
|
||||
}
|
||||
|
||||
impl ::protobuf::Message for Identity {
|
||||
@ -94,7 +105,7 @@ impl ::protobuf::Message for Identity {
|
||||
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 {
|
||||
@ -127,7 +138,7 @@ impl ::protobuf::Message for Identity {
|
||||
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 !self.pubkey.is_empty() {
|
||||
os.write_bytes(1, &self.pubkey)?;
|
||||
}
|
||||
@ -150,13 +161,13 @@ impl ::protobuf::Message for Identity {
|
||||
&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
|
||||
}
|
||||
|
||||
@ -208,14 +219,14 @@ impl ::protobuf::Message for Identity {
|
||||
|
||||
impl ::protobuf::Clear for Identity {
|
||||
fn clear(&mut self) {
|
||||
self.clear_pubkey();
|
||||
self.clear_signature();
|
||||
self.pubkey.clear();
|
||||
self.signature.clear();
|
||||
self.unknown_fields.clear();
|
||||
}
|
||||
}
|
||||
|
||||
impl ::std::fmt::Debug for Identity {
|
||||
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)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user