kitsune2_api/proto/gen/kitsune2.wire.rs
1// This file is @generated by prost-build.
2/// A Kitsune2 wire protocol message.
3///
4/// This is the top-level encoding
5/// that will be transferred between Kitsune2 peers. Most communications
6/// between peers to make Kitsune2 actually function will be encoded
7/// separately inside the payload of TY_MODULE type messages.
8#[derive(Clone, PartialEq, ::prost::Message)]
9pub struct K2Proto {
10 /// The type of this message.
11 #[prost(enumeration = "k2_proto::K2WireType", tag = "1")]
12 pub ty: i32,
13 /// The payload or content of this message.
14 #[prost(bytes = "bytes", tag = "2")]
15 pub data: ::prost::bytes::Bytes,
16 /// If the Ty requires that a space be specified, this is it.
17 ///
18 /// Kitsune is divided up into multiple dht "spaces" and peers
19 /// join and communicate over these spaces. These bytes identify
20 /// the space within which this message is communicating.
21 #[prost(bytes = "bytes", optional, tag = "3")]
22 pub space: ::core::option::Option<::prost::bytes::Bytes>,
23 /// If the Ty requires a module impl be specified, this is it.
24 ///
25 /// Modules include specific sub-protocols to communicate with each other,
26 /// so those messages must be routed to the correct module.
27 ///
28 /// This string is the module routing info. E.g. "gossip", "fetch", "sharding".
29 #[prost(string, optional, tag = "4")]
30 pub module: ::core::option::Option<::prost::alloc::string::String>,
31}
32/// Nested message and enum types in `K2Proto`.
33pub mod k2_proto {
34 /// Enumeration of the types of messages that can be sent between peers.
35 ///
36 /// We are using this enum field to distinguish between top-level messages,
37 /// rather than protobuf's oneof because of the downsides of upgrading oneofs.
38 #[derive(
39 Clone,
40 Copy,
41 Debug,
42 PartialEq,
43 Eq,
44 Hash,
45 PartialOrd,
46 Ord,
47 ::prost::Enumeration
48 )]
49 #[repr(i32)]
50 pub enum K2WireType {
51 /// The "UNSPECIFIED" type for future message types.
52 ///
53 /// In general, peers should ignore unspecified messages, but
54 /// should still count them toward any ratelimiting metrics.
55 Unspecified = 0,
56 /// This message is preflight data.
57 ///
58 /// The implementor is responsible for encoding any module-specific
59 /// requirements within the data payload of this message type.
60 /// For example, if peers are required to include the "dht_v1" module
61 /// to communicate with each other, they should reject preflight to
62 /// peers that do not include that module.
63 Preflight = 1,
64 /// This is a notification or fire-and-forget message from a peer.
65 ///
66 /// This type requires that a "space" be specified.
67 Notify = 2,
68 /// This is a module communication.
69 ///
70 /// Most of Kitsune2's communications will likely proceed between
71 /// Kitsune2's modules.
72 ///
73 /// This type requires that a "space" be specified.
74 /// This type requires that a "module" be specified.
75 Module = 3,
76 /// This message indicates a general disconnect, with the reason
77 /// or context specified in the data payload.
78 ///
79 /// We may add additional specific disconnect codes in the future.
80 Disconnect = 15,
81 }
82 impl K2WireType {
83 /// String value of the enum field names used in the ProtoBuf definition.
84 ///
85 /// The values are not transformed in any way and thus are considered stable
86 /// (if the ProtoBuf definition does not change) and safe for programmatic use.
87 pub fn as_str_name(&self) -> &'static str {
88 match self {
89 Self::Unspecified => "UNSPECIFIED",
90 Self::Preflight => "PREFLIGHT",
91 Self::Notify => "NOTIFY",
92 Self::Module => "MODULE",
93 Self::Disconnect => "DISCONNECT",
94 }
95 }
96 /// Creates an enum from field names used in the ProtoBuf definition.
97 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
98 match value {
99 "UNSPECIFIED" => Some(Self::Unspecified),
100 "PREFLIGHT" => Some(Self::Preflight),
101 "NOTIFY" => Some(Self::Notify),
102 "MODULE" => Some(Self::Module),
103 "DISCONNECT" => Some(Self::Disconnect),
104 _ => None,
105 }
106 }
107 }
108}