Skip to content
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

Remove UPayload #108

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bytes = { version = "1.5" }
chrono = { version = "0.4.32" }
mediatype = "0.19"
once_cell = { version = "1.19" }
protobuf = { version = "3.3" }
protobuf = { version = "3.3", features = ["with-bytes"] }
rand = { version = "0.8" }
regex = { version = "1.10" }
url = { version = "2.5" }
Expand Down
4 changes: 3 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ use std::fs;
use std::path::Path;
use std::path::PathBuf;

use protobuf_codegen::Customize;

const UPROTOCOL_BASE_URI: &str =
"https://raw.githubusercontent.com/eclipse-uprotocol/up-spec/main/up-core-api/uprotocol";

Expand All @@ -26,7 +28,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 Expand Up @@ -73,6 +74,7 @@ fn get_and_build_protos(
.protoc()
// use vendored protoc instead of relying on user provided protobuf installation
.protoc_path(&protoc_bin_vendored::protoc_bin_path().unwrap())
.customize(Customize::default().tokio_bytes(true))
.include(proto_folder)
.inputs(proto_files)
.cargo_out_dir(output_folder)
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