-
Notifications
You must be signed in to change notification settings - Fork 14
Rust API #249
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
Merged
Merged
Rust API #249
Changes from all commits
Commits
Show all changes
127 commits
Select commit
Hold shift + click to select a range
37ec326
rust gravity node stuff
astrauc 08dae6a
readme
astrauc a667bd9
readme
astrauc ff666bb
readme
astrauc 7282566
notes as of 6/10/25
astrauc a45c38d
notes 6/10/25
astrauc b3afd68
gravity can now publish basic messages
astrauc 3e25201
updates 6.12.25
astrauc 7ccfaea
splitting into separate files
astrauc c647095
formatting
astrauc 98a55c2
protobufs and better file distribution
astrauc e0f1e67
updates 06.13.25
astrauc 4178027
some trivial GravityNode methods
astrauc c0fecc7
even more of the easy-to-implement stuff
astrauc 1907f35
updates 6.25.25
astrauc f209762
all trivial GravityNode functions
astrauc 91022d9
very very rough subscriber implementation
astrauc f81a4be
some basic GravityDataProduct implementations
astrauc b3eb8f0
updates 6.27.25
astrauc ed69891
formatting for README
astrauc b750be8
working for populate_message
astrauc d46a1bb
starting to reformat
astrauc bde3def
subscriber works as idiomatic rust!
astrauc 68a4a9c
Merge pull request #1 from astrauc/subscriber
astrauc 1da057c
cleaning up
astrauc 468d2cb
more cleaning up
astrauc fe638f3
more cleaning up
astrauc 04741a7
redefining populate_message to not modify gravity source code
astrauc 8fac6d5
update 7.4.25
astrauc f0c5efd
subscribe/unsubscribe complete
astrauc 277ac89
requestor/provider
astrauc 3430615
now a library
astrauc 9554347
gdp + futureresponse + more gn
astrauc d6df61c
some tests and bug fixes
astrauc 144e441
some tests and bug fixes
astrauc ce34a73
starrting to clean up
astrauc 8698418
cleaning up
astrauc 246f83f
a few more tests
astrauc 9f3bb66
split cpp src files
astrauc be345b0
function args to string slice instead of String
astrauc 331405a
function args to string slice instead of String
astrauc dd30175
data product test
astrauc 14edf41
delete
astrauc de8d1a9
&str as param
astrauc 7752c01
weird heartbeat segfaults fixed (weakly tested)
astrauc f4b7101
cleaning
astrauc 3c534b0
fn for optional params
astrauc b49c604
traits now take mutable refs to self
astrauc d0d3c94
drop/move tests
astrauc 79e4b5b
general directories
astrauc 0044684
new build strategy
astrauc 16d122c
naming conventions
astrauc 8773daa
moved cargo.toml to top level
astrauc 7827dca
fix file paths
astrauc ede688c
added option to build libraries only
astrauc 01a3436
partial static linking (gravity but not dependencies)
astrauc 0cd6f79
protobuf linked statically (tested only on same machine)
astrauc f8da484
protobuf static
astrauc 88d6b4a
protobuf static
astrauc 768970f
fixing branching isues
astrauc 080a22e
static zmq
astrauc b217b2f
remove fmt dependency (experimental)
astrauc 0dbe9c7
clean
astrauc ebc61b0
option for building only library
astrauc 6b9030f
license file
astrauc 7d16961
categories
astrauc 361e6ae
change outdir
astrauc 1daeb9a
include directory
astrauc ce71f83
include directory
astrauc 593a549
include directory
astrauc 55d7fc6
include directory
astrauc 9997a7a
adjust so only out_dir is modified
astrauc aee223c
starting rustdoc
astrauc bb5aa0c
docs
astrauc cac0a2c
change where to put autogenerated files
astrauc 0973158
change where to put autogenerated files
astrauc 111298b
change where to put autogenerated files
astrauc 433c55d
fix build issues
astrauc 8814d83
final gdp methods
astrauc 1c3392d
warnings
astrauc 1bfe515
warnings
astrauc 33e22c8
warnings
astrauc 3d9c0e9
target directrory
astrauc 9b2277b
Merge pull request #5 from astrauc/static_cmake
astrauc 6a49995
cleaning
astrauc d28fd7f
cleaning
astrauc 3a1ff0d
request optional parameters migrated out of rust
astrauc 116e00f
heartbeat listener optional params gone
astrauc 74f28f1
subscription monitor optional params
astrauc 6bcccd1
Merge branch 'aphysci:master' into master
astrauc 502eb64
clear subscription monitornaming
astrauc 3fe3c45
cmake build release mode
astrauc 5031119
Merge branch 'master' of github.com:astrauc/gravity
astrauc 349680c
add subscriber with Arc
astrauc 55bc18c
add subscriber with Arc
astrauc e011715
unique ownership with tokens (subscriber)
astrauc 9977215
wrappers
astrauc fa902d4
tokens fully implemented
astrauc 7b1dcde
example start
astrauc 0c99335
pubsub runnable example
astrauc f7e4bc1
basic service runnable example
astrauc 86e1ed9
changing format of protobuf includes
astrauc 4f34cd3
detokenize hb listerner and service provider
astrauc 9232129
Merge branch 'aphysci:master' into master
astrauc d8f9f61
Merge pull request #8 from astrauc/arcs
astrauc 7a11b7e
formatting
astrauc d02f6af
cleanups
astrauc cda366a
Merge branch 'aphysci:master' into master
astrauc d9235df
service example working
astrauc 48b671e
forgot to add autogenerated protobufs...
astrauc b663049
dependencies in toml
astrauc 56af042
remove Cargo.lock
astrauc d1f8c47
remove cmakelists
astrauc 36b9566
cmake fix
astrauc d61e9ca
bad library include
astrauc 0e4e1e0
gdp not mutable fixed
astrauc 4215ea4
option to only build static libraries
astrauc bf8484b
fallback when no tags present
astrauc ab529b0
add mut keyword to some
astrauc e3b5c1e
clarifying build instructions
astrauc 4efdaec
doc tests now succeed
astrauc 3ad6f83
spdlog external/internal issue
astrauc 6fc5da6
dependencies information
astrauc 9b69f08
cargo/rustc dependency
astrauc 5a7ae8c
note about cmake
astrauc 6d9d008
updating and formatting rustdoc
astrauc 2a932e2
Merge branch 'aphysci:master' into master
astrauc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| include | ||
| target/ | ||
| *.tgz | ||
| *.tar.gz | ||
| *.o | ||
|
|
@@ -26,3 +27,4 @@ install | |
| build | ||
| .vscode | ||
| .vs | ||
| Cargo.lock | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [package] | ||
| name = "gravity" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
| description = "Rust bindings for the Gravity software framework" | ||
| readme = "README.md" | ||
| license-file = "LICENSE" | ||
| repository = "https://github.com/astrauc/gravity.git" | ||
| keywords = ["FFI", "C++", "Gravity"] | ||
| exclude = ["src/api/rust/target"] | ||
| build = "src/api/rust/build.rs" | ||
|
|
||
| [lib] | ||
| path = "src/api/rust/src/lib.rs" | ||
|
|
||
| [dependencies] | ||
| cxx = "1.0.158" | ||
| protobuf = "3.7.2" | ||
|
|
||
| [build-dependencies] | ||
| cxx-build = "1.0.158" | ||
| cmake = "0.1" | ||
| protobuf-codegen = "3.7.2" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| target/ | ||
| build/ | ||
| Cargo.lock | ||
| *.log | ||
| Testing/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Rust for Gravity | ||
|
|
||
| A Rust API for gravity | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Dependencies | ||
|
|
||
| **Requires cargo 1.85 or later** | ||
| On linux, this can be easily installed through the following: | ||
| ```sh | ||
| sudo apt install rustup | ||
| rustup update stable | ||
| ``` | ||
|
|
||
| Rustup will automatically install the latest stable release of rust compiler. | ||
|
|
||
|
|
||
| Before you add it to your ```Cargo.toml```, ensure that you have all the Gravity dependencies installed, specified in the [Gravity Build Guide](https://github.com/aphysci/gravity/wiki/GravitySetup). | ||
|
|
||
| Not all are necessary, just g++, cmake, bison, flex. | ||
|
|
||
| In linux: | ||
| ```sh | ||
| sudo apt install cmake g++ bison flex | ||
| ``` | ||
| Using cmake version 4.x.x or later does not work with Gravity. apt installs version 3.28 which has been tested with Gravity and the Cargo build. | ||
|
|
||
| Then, add the crate to your Cargo.toml: | ||
| ```toml | ||
| [dependencies] | ||
| gravity = { git = "REPOSITORY_URL" } | ||
| ``` | ||
|
|
||
| You are done! Now you can use Gravity from your Rust application! | ||
|
|
||
| > [!NOTE] | ||
| > Using Gravity this way does not create/run the ServiceDirectory. Follow the [Gravity Build Guide](https://github.com/aphysci/gravity/wiki/GravitySetup) to set that up. | ||
| > | ||
|
|
||
| ## Tests | ||
| To run the unit tests, you need a Service Directory running. Then simply run ``` cargo test ```. As long you are not in the examples folder, the folder you run it in does not matter. (If you are in the examples it will run the specific example) | ||
|
|
||
| ## Runnable examples | ||
|
|
||
| Once there is a ServiceDirectory setup, go into the example directory you want to run and ``` cargo run ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include "RustFutureResponse.h" | ||
|
|
||
| namespace gravity { | ||
|
|
||
| std::shared_ptr<FutureResponse> rustNewFutureResponse(const char* arrayPtr, int size) | ||
| { | ||
| return std::shared_ptr<FutureResponse>(new FutureResponse(arrayPtr, size)); | ||
| } | ||
|
|
||
| void rustSetResponse(const std::unique_ptr<FutureResponse>& fr, const std::unique_ptr<GravityDataProduct>& response) | ||
| { | ||
| fr->setResponse(*response); | ||
| } | ||
|
|
||
|
|
||
| } // namespace gravity |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #ifndef RUSTFUTURERESPONSE_H_ | ||
| #define RUSTFUTURERESPONSE_H_ | ||
|
|
||
|
|
||
| #include <FutureResponse.h> | ||
|
|
||
|
|
||
|
|
||
| namespace gravity | ||
| { | ||
| /* Future response things*/ | ||
| std::shared_ptr<FutureResponse> rustNewFutureResponse(const char* arrayPtr, int size); | ||
|
|
||
| void rustSetResponse(const std::unique_ptr<FutureResponse>& fr, const std::unique_ptr<GravityDataProduct>& response); | ||
|
|
||
|
|
||
|
|
||
| } // namespace gravity | ||
|
|
||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this file at first glance - this covers the setup notes I asked for.