Skip to content
Open
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.idea
target/
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[workspace]
members = [
"rust"
]
31 changes: 31 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "stac-proto"
version = "0.1.0"
authors = ["sunny-g <sunny.gonna@gmail.com>"]
edition = "2018"
publish = false
build = "build.rs"

[lib]
name = "stac_proto"
path = "src/lib.rs"

[dependencies]
futures = "0.1"
grpcio = { version = "0.4", features = ["openssl"] }
protobuf = { version = "2", features = ["with-serde"] }
serde = { version = "1.0", features = ["derive"] }

[dev-dependencies]
futures03 = { package = "futures", version = "0.3", features = ["compat", "executor"] }
futures03-test = { package = "futures-test", version = "0.3" }
lazy_static = "1.4"

[build-dependencies]
lazy_static = "1.4"
protobuf-codegen = { version = "2" }
protoc-grpcio = "1.1"

[features]
default = ["with-serde"]
with-serde = ["protobuf/with-serde"]
15 changes: 15 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# stac-proto

## Install

```bash
$ cargo build

# to rebuild proto modules
REBUILD=true cargo build
# then in the `geometry`, `query` and `stac` modules,
# add the line `use serde::{Deserialize, Serialize};` to the other imports.
```

See `tests/mod.rs` for a full example using the client, though this will
require a valid authentication token.
36 changes: 36 additions & 0 deletions rust/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
extern crate protoc_grpcio;

fn main() {
if std::env::var("REBUILD").is_err() {
return;
}

let proto_lib_root = "src/proto";
let proto_root = "../proto";
let proto_files = [
"epl/protobuf/geometry.proto",
"epl/protobuf/query.proto",
"epl/protobuf/stac.proto",
"epl/protobuf/geometry_service.proto",
"epl/protobuf/stac_service.proto",
];

println!("cargo:rerun-if-changed={}", proto_root);
protoc_grpcio::compile_grpc_protos(
&proto_files,
&[proto_root],
&proto_lib_root,
Some(protobuf_codegen::Customize {
serde_derive: Some(true),
..Default::default()
}),
)
.expect("Failed to compile gRPC definitions!");

println!(
"gRPC definitions successfully created!\
Be sure to add a `use serde::{{Serialize, Deserialize}};` line to the \
non-service modules.\
"
)
}
11 changes: 11 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! stac-proto

mod proto;

pub use proto::geometry::*;
pub use proto::geometry_service::*;
pub use proto::geometry_service_grpc::*;
pub use proto::query::*;
pub use proto::stac::*;
pub use proto::stac_service::*;
pub use proto::stac_service_grpc::*;
Loading