Skip to content

Commit

Permalink
Add generated code
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Gisondi <antonio.gisondi@secomind.com>
  • Loading branch information
harlem88 committed Oct 10, 2023
1 parent 2f46186 commit ca22261
Showing 1 changed file with 100 additions and 9 deletions.
109 changes: 100 additions & 9 deletions rust/astarte-message-hub-proto/src/astarteplatform.msghub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,77 @@ pub mod astarte_data_type {
AstarteObject(super::AstarteDataTypeObject),
}
}
/// Astarte Error type
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MessageHubError {
/// Error enum value.
#[prost(enumeration = "message_hub_error::ErrorCode", tag = "1")]
pub error_code: i32,
/// Human-readable string describing the error.
#[prost(string, tag = "2")]
pub error_description: ::prost::alloc::string::String,
}
/// Nested message and enum types in `MessageHubError`.
pub mod message_hub_error {
/// A list specifying general categories of Astarte Message Hub error.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ErrorCode {
/// Unknown error.
Unknown = 0,
/// Error occurred when trying to send an invalid data.
AstarteInvalidData = 1,
/// Error returned by the Astarte SDK.
AstarteSdkError = 2,
/// Error occurred during conversion between types.
ConversionError = 3,
}
impl ErrorCode {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
ErrorCode::Unknown => "UNKNOWN",
ErrorCode::AstarteInvalidData => "ASTARTE_INVALID_DATA",
ErrorCode::AstarteSdkError => "ASTARTE_SDK_ERROR",
ErrorCode::ConversionError => "CONVERSION_ERROR",
}
}
}
}
/// Astarte message result used when receiving data or an error from Astarte.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct AstarteMessageResult {
#[prost(oneof = "astarte_message_result::Result", tags = "1, 2")]
pub result: ::core::option::Option<astarte_message_result::Result>,
}
/// Nested message and enum types in `AstarteMessageResult`.
pub mod astarte_message_result {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Result {
/// A message that contains data sent from Astarte.
#[prost(message, tag = "1")]
AstarteMessage(super::AstarteMessage),
/// A message that contains a specific Astarte Message Hub error.
#[prost(message, tag = "2")]
HubError(super::MessageHubError),
}
}
/// Astarte message to be used when sending data to Astarte.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -181,6 +252,26 @@ pub struct Node {
#[prost(bytes = "vec", repeated, tag = "2")]
pub interface_jsons: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
/// Astarte Data result used when receiving data or an error from Astarte.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct MessageHubResult {
#[prost(oneof = "message_hub_result::Result", tags = "1, 2")]
pub result: ::core::option::Option<message_hub_result::Result>,
}
/// Nested message and enum types in `MessageHubResult`.
pub mod message_hub_result {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Result {
/// A message that contains an empty value for success response.
#[prost(message, tag = "1")]
EmptyMessage(::pbjson_types::Empty),
/// A message that contains a specific Astarte Message Hub error.
#[prost(message, tag = "2")]
HubError(super::MessageHubError),
}
}
/// Generated client implementations.
pub mod message_hub_client {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
Expand Down Expand Up @@ -256,7 +347,7 @@ pub mod message_hub_client {
&mut self,
request: impl tonic::IntoRequest<super::Node>,
) -> Result<
tonic::Response<tonic::codec::Streaming<super::AstarteMessage>>,
tonic::Response<tonic::codec::Streaming<super::AstarteMessageResult>>,
tonic::Status,
> {
self.inner
Expand All @@ -278,7 +369,7 @@ pub mod message_hub_client {
pub async fn send(
&mut self,
request: impl tonic::IntoRequest<super::AstarteMessage>,
) -> Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
) -> Result<tonic::Response<super::MessageHubResult>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -298,7 +389,7 @@ pub mod message_hub_client {
pub async fn detach(
&mut self,
request: impl tonic::IntoRequest<super::Node>,
) -> Result<tonic::Response<::pbjson_types::Empty>, tonic::Status> {
) -> Result<tonic::Response<super::MessageHubResult>, tonic::Status> {
self.inner
.ready()
.await
Expand All @@ -325,7 +416,7 @@ pub mod message_hub_server {
pub trait MessageHub: Send + Sync + 'static {
///Server streaming response type for the Attach method.
type AttachStream: futures_core::Stream<
Item = Result<super::AstarteMessage, tonic::Status>,
Item = Result<super::AstarteMessageResult, tonic::Status>,
>
+ Send
+ 'static;
Expand All @@ -339,12 +430,12 @@ pub mod message_hub_server {
async fn send(
&self,
request: tonic::Request<super::AstarteMessage>,
) -> Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
) -> Result<tonic::Response<super::MessageHubResult>, tonic::Status>;
/// This function should be used to detach a node from an instance of the Astarte message hub.
async fn detach(
&self,
request: tonic::Request<super::Node>,
) -> Result<tonic::Response<::pbjson_types::Empty>, tonic::Status>;
) -> Result<tonic::Response<super::MessageHubResult>, tonic::Status>;
}
#[derive(Debug)]
pub struct MessageHubServer<T: MessageHub> {
Expand Down Expand Up @@ -412,7 +503,7 @@ pub mod message_hub_server {
T: MessageHub,
> tonic::server::ServerStreamingService<super::Node>
for AttachSvc<T> {
type Response = super::AstarteMessage;
type Response = super::AstarteMessageResult;
type ResponseStream = T::AttachStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
Expand Down Expand Up @@ -450,7 +541,7 @@ pub mod message_hub_server {
impl<
T: MessageHub,
> tonic::server::UnaryService<super::AstarteMessage> for SendSvc<T> {
type Response = ::pbjson_types::Empty;
type Response = super::MessageHubResult;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
Expand Down Expand Up @@ -486,7 +577,7 @@ pub mod message_hub_server {
struct DetachSvc<T: MessageHub>(pub Arc<T>);
impl<T: MessageHub> tonic::server::UnaryService<super::Node>
for DetachSvc<T> {
type Response = ::pbjson_types::Empty;
type Response = super::MessageHubResult;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
Expand Down

0 comments on commit ca22261

Please sign in to comment.