Skip to content

Commit

Permalink
Adopt changes from uProtocol Spec
Browse files Browse the repository at this point in the history
The UPayload structure has been removed from UMessage. The code has
been adapted accordingly.

Also-by: Kai Hudalla <kai.hudalla@bosch.com>
  • Loading branch information
AnotherDaniel authored and sophokles73 committed May 21, 2024
1 parent 57c3c8c commit 3760db3
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 619 deletions.
1 change: 0 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
format!("{}/uuid.proto", UPROTOCOL_BASE_URI).as_str(),
format!("{}/uri.proto", UPROTOCOL_BASE_URI).as_str(),
format!("{}/uattributes.proto", UPROTOCOL_BASE_URI).as_str(),
format!("{}/upayload.proto", UPROTOCOL_BASE_URI).as_str(),
format!("{}/umessage.proto", UPROTOCOL_BASE_URI).as_str(),
format!("{}/ustatus.proto", UPROTOCOL_BASE_URI).as_str(),
// not used in the SDK yet, but for completeness sake
Expand Down
11 changes: 3 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,17 @@
// up_core_api types used and augmented by up_rust - symbols re-exported to toplevel, errors are module-specific
mod rpc;
pub use rpc::{RpcClient, RpcClientResult};
pub use rpc::{RpcMapper, RpcMapperError};
pub use rpc::{RpcPayload, RpcPayloadResult, RpcResult};
pub use rpc::{RpcClient, RpcClientResult, RpcResult};

mod uattributes;
pub use uattributes::{
PublishValidator, RequestValidator, ResponseValidator, UAttributesValidator,
UAttributesValidators,
};
pub use uattributes::{UAttributes, UAttributesError, UMessageType, UPriority};
pub use uattributes::{UAttributes, UAttributesError, UMessageType, UPayloadFormat, UPriority};

mod umessage;
pub use umessage::{UMessage, UMessageBuilder, UMessageBuilderError};

mod upayload;
pub use upayload::{UPayload, UPayloadError, UPayloadFormat};
pub use umessage::{UMessage, UMessageBuilder, UMessageError};

mod uri;
pub use uri::{UUri, UUriError};
Expand Down
2 changes: 0 additions & 2 deletions src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
********************************************************************************/

mod rpcclient;
mod rpcmapper;
mod rpcresult;

pub use rpcclient::*;
pub use rpcmapper::*;
pub use rpcresult::*;
17 changes: 3 additions & 14 deletions src/rpc/rpcclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

use async_trait::async_trait;

use crate::{RpcMapperError, UMessage, UPayload, UPriority, UUri};
use crate::{UMessage, UMessageError, UUri};

pub type RpcClientResult = Result<UMessage, RpcMapperError>;
pub type RpcClientResult = Result<UMessage, UMessageError>;

/// `RpcClient` is an interface used by code generators for uProtocol services defined in `.proto` files such as
/// the core uProtocol services found in [uProtocol Core API](https://github.com/eclipse-uprotocol/up-spec/tree/main/up-core-api).
Expand All @@ -35,21 +35,10 @@ pub trait RpcClient: Send + Sync {
///
/// * `method` - The URI of the method to be invoked. For example, in long form: "/example.hello_world/1/rpc.SayHello".
/// * `request` - The request message to be sent to the server.
/// * `priority` - The priority to use for sending the request and corresponding response messages. Must be at least
/// [`UPriority::UPRIORITY_CS4`], which is also the default if not specified explicitly.
/// * `ttl` - The request's time-to-live in milliseconds.
/// * `token` - The authorization token to use for TAP.
///
/// # Returns
///
/// Returns a `RpcClientResult` which contains the response message.
/// If the invocation fails, it contains a `UStatus` detailing the failure reason.
async fn invoke_method(
&self,
method: UUri,
request: UPayload,
priority: Option<UPriority>,
ttl: Option<u32>,
token: Option<String>,
) -> RpcClientResult;
async fn invoke_method(&self, method: UUri, request: UMessage) -> RpcClientResult;
}
Loading

0 comments on commit 3760db3

Please sign in to comment.