-
Notifications
You must be signed in to change notification settings - Fork 332
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
Complete example for compiling and decoding ConnectionEnd with Prost. #139
Conversation
let buf = Bytes::from(_response.value); | ||
|
||
let conn_end:items::ConnectionEnd = items::ConnectionEnd::decode(buf).unwrap(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andynog This is perhaps the most important part for decoding.
One major part we should decide is how to handle the The .proto file in this commit is as follows (everything that starts with syntax = "proto3";
package items;
import "proto/gogo.proto";
//import "ibc/commitment/commitment.proto";
// ConnectionEnd defines a stateful object on a chain connected to another separate
// one.
// NOTE: there must only be 2 defined ConnectionEnds to establish a connection
// between two chains.
message ConnectionEnd {
option (gogoproto.goproto_getters) = false;
// connection identifier.
string id = 1 [(gogoproto.customname) = "ID", (gogoproto.moretags) = "yaml:\"id\""];
// client associated with this connection.
string client_id = 2 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""];
// opaque string which can be utilised to determine encodings or protocols for
// channels or packets utilising this connection
repeated string versions = 3;
// current state of the connection end.
State state = 4;
// counterparty chain associated with this corparty = 5 [(gogoprotonnection.
// Counterparty counte.nullable) = false];
}
// State defines if a connection is in one of the following states:
// INIT, TRYOPEN, OPEN or UNINITIALIZED.
enum State {
option (gogoproto.goproto_enum_prefix) = false;
// Default State
STATE_UNINITIALIZED_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "UNINITIALIZED"];
// A connection end has just started the opening handshake.
STATE_INIT = 1 [(gogoproto.enumvalue_customname) = "INIT"];
// A connection end has acknowledged the handshake step on the counterparty chain.
STATE_TRYOPEN = 2 [(gogoproto.enumvalue_customname) = "TRYOPEN"];
// A connection end has completed the handshake.
STATE_OPEN = 3 [(gogoproto.enumvalue_customname) = "OPEN"];
} The resulting .rs file is as follows: /// ConnectionEnd defines a stateful object on a chain connected to another separate
/// one.
/// NOTE: there must only be 2 defined ConnectionEnds to establish a connection
/// between two chains.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ConnectionEnd {
/// connection identifier.
#[prost(string, tag="1")]
pub id: std::string::String,
/// client associated with this connection.
#[prost(string, tag="2")]
pub client_id: std::string::String,
/// opaque string which can be utilised to determine encodings or protocols for
/// channels or packets utilising this connection
#[prost(string, repeated, tag="3")]
pub versions: ::std::vec::Vec<std::string::String>,
/// current state of the connection end.
///
/// // counterparty chain associated with this connection.
/// Counterparty counterparty = 5 [(gogoproto.nullable) = false];
#[prost(enumeration="State", tag="4")]
pub state: i32,
}
/// State defines if a connection is in one of the following states:
/// INIT, TRYOPEN, OPEN or UNINITIALIZED.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum State {
/// Default State
UninitializedUnspecified = 0,
/// A connection end has just started the opening handshake.
Init = 1,
/// A connection end has acknowledged the handshake step on the counterparty chain.
Tryopen = 2,
/// A connection end has completed the handshake.
Open = 3,
} TODOs:
|
@@ -6,7 +6,7 @@ | |||
trivial_casts, | |||
trivial_numeric_casts, | |||
unused_import_braces, | |||
unused_qualifications, | |||
// unused_qualifications, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for commenting this out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has to do with the generated Rust code which prost
generated, for instance: pub versions: ::std::vec::Vec<std::string::String>
. This seems to be the offending part that triggers the unused_qualifications warning, but I have not digged into it.
Any thoughts or prior experience with unused_qualifications ? I almost forgot about this. We should probably fix & enable the warning again it before merge.
Closes: #130
Description
For contributor use:
docs/
) and code commentsFiles changed
in the Github PR explorer