Skip to content

Commit

Permalink
Move rusp-run binary to the main rusp crate and improve all documenta…
Browse files Browse the repository at this point in the history
…tion

Signed-off-by: Daniel Egger <[email protected]>
  • Loading branch information
therealprof committed Jan 10, 2025
1 parent 01f21d4 commit b0d44af
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 60 deletions.
4 changes: 0 additions & 4 deletions rhai-rusp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ readme = "README.md"
repository = "https://github.com/axiros/rusp"

[dependencies]
clap = { version = "4", features = ["derive"] }
rhai = { workspace = true }
rusp-lib = { workspace = true }
anyhow = { workspace = true }
quick-protobuf = { workspace = true }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }

[[bin]]
name = "rusp-run"
31 changes: 4 additions & 27 deletions rhai-rusp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# `rhai-rusp`

`rhai-rusp` is a new approach to address your [USP][] protocol needs by
providing [Rhai][] bindings for the [rusp-lib
crate](https://crates.io/crates/rusp-lib), thus providing scripting capabilities
providing [Rhai][] bindings for the [rusp-lib crate](https://crates.io/crates/rusp-lib), thus providing scripting capabilities
to USP in Rhai for either standalone runners or [Rust][] applications which can
embed the [Rhai][] interpreter together with the `rhai-rusp` bindings.

Expand All @@ -28,32 +27,10 @@ The usual steps to embed a Rhai interpreter with rusp support are:
4. Execute the `Rhai` AST via `engine.run_ast(ast)`
5. Handle errors, err... profit!

## How to use `rhai-rusp` directly?

Currently we're including a simply binary called `rusp-run`, demonstrating how
to embed the bindings and allowing you to execute `Rhai` code directly from the
commandline, read either from `stdin` or a file.
There's also the `rusp-run` binary as part of the [rusp crate](https://crates.io/crates/rusp) which you can install via:

```
# rusp-run --script 'let body = rusp::get_builder().with_max_depth(1).with_params(["Device."]).build();
let msg = rusp::msg_builder().with_msg_id ("Foo").with_body (body).build();
print (msg)'
{
"Header": {
"msg_id": "Foo",
"msg_type": "GET"
},
"Body": {
"Request": {
"Get": {
"param_paths": [
"Device."
],
"max_depth": 1
}
}
}
}
# cargo install rusp
```

## What else?
Expand All @@ -78,4 +55,4 @@ Licence
[Rhai]: https://rhai.rs
[Rust]: https://www.rust-lang.org/
[USP]: https://usp.technology/
[Axiros]: https://www.axiros.com/
[Axiros]: https://www.axiros.com/
7 changes: 6 additions & 1 deletion rusp-bin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,18 @@ version = "0.95.0"
repository = "axiros/rusp"

[dependencies]
rhai = { workspace = true }
anyhow = { workspace = true }
clap = { version = "4", features = ["derive"] }
clap = { version = "4", default-features = false, features = ["std", "derive"] }
quick-protobuf = { workspace = true }
rusp-lib = { version = "0.95", path = "../rusp-lib" }
rhai-rusp = { version = "0.95", path = "../rhai-rusp" }
serde = { workspace = true }
serde_derive = { workspace = true }
serde_json = { workspace = true }

[[bin]]
name = "rusp"

[[bin]]
name = "rusp-run"
65 changes: 47 additions & 18 deletions rusp-bin/README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,80 @@
![Continuous integration](https://github.com/axiros/rusp/workflows/Continuous%20integration/badge.svg)

# rusp-bin
# rusp

This crate contains the application part of Rusp, which contains:

* A **rusp** binary granting access to library functionality via command line. Included functionality at the moment are:
* A `rusp` application, granting access to library functionality via command line. Included functionality at the moment are:
* Decoding of **USP** Msg Protobuf bytestreams from standard input
* Decoding of **USP** Msg Protobuf bytestreams from file(s)
* Decoding of **USP** Record Protobuf bytestreams from standard input
* Decoding of **USP** Record Protobuf bytestreams from file(s)
* Extraction of **USP** Msg Protobuf bytestreams from the payload of a **USP** Record Protobuf bytestream
* Generation of **USP** Msg Protobuf bytestreams and C char arrays for selected messages and Error
* A `rusp-run` application, providing a simple frontend to the `rhai-rusp` bindings via an embedded [Rhai][] interpreter

## How to use the rusp binary?
In order to download, compile and install the `rusp` binary it is sufficient to have a stable [Rust][] environment and run:

```
# cargo install rusp
```

## How to use the `rusp` binary?

**rusp** includes a binary with the same name demonstrating some of the uses.

At the moment this mostly allows converting Protobuf encapsulated USP **Record** and **Msg** structures into human-readable text and other useful formats like code and to extracting a **Msg** structure from a **Record**.

Currently, it also still supports synthesizing USP Records via command line, however this feature is going to be phased out soon in favour of something way better. 😉
Currently, it also still supports synthesizing USP Records via command line, however this feature is going to be phased out soon in favour of the way more flexible `rhai-rusp`.

In order to download, compile and install the `rusp` binary it is sufficient to have a stable Rust environment and run:
## How to use the `rhai-rusp` binary?

We are now also including a simply binary called `rusp-run`, demonstrating how
to embed the bindings and allowing you to execute `Rhai` code directly via
command line, read either from `stdin` or a file.

```
# cargo install rusp
# rusp-run --script 'let body = rusp::get_builder().with_max_depth(1).with_params(["Device."]).build();
let msg = rusp::msg_builder().with_msg_id ("Foo").with_body (body).build();
print (msg)'
{
"Header": {
"msg_id": "Foo",
"msg_type": "GET"
},
"Body": {
"Request": {
"Get": {
"param_paths": [
"Device."
],
"max_depth": 1
}
}
}
}
```

After this you should be able to use the `rusp` binary, which has built-in help for all the commands to guide the way.

## What else?

You may use this crate however you like under the **BSD 3-Clause Licence**.

The toolkit is still far from feature complete but already a big aid in our product development and also helped to find one or the other discrepancy in the standard.
You may use this crate however you like under the [BSD 3-Clause Licence](LICENSE).

Feel free to spread the word or drop us a note if you like it. Collaboration on this crate is highly welcome as are pull requests in [our GitHub repo](https://github.com/axiros/rusp/).
Feel free to spread the word or drop us a note if you like it. Collaboration on
this crate is highly welcome as are pull requests in [our GitHub
repo](https://github.com/axiros/rusp/).

## Contact us

If you are in need of software for **USP** management software (agent, controller or testing) or expertise please get in touch with us via our [web form](https://www.axiros.com). We're also happy to solve all other device management and monitoring needs!

[Rust]: https://www.rust-lang.org/
[USP]: https://usp.technology/
[BBF]: https://www.broadband-forum.org/
[Axiros]: https://www.axiros.com/
If you are in need of software for [USP][] management software (agent,
controller or testing) or expertise please get [in touch with us][Axiros]. We're
also happy to solve all other device management and monitoring needs!

Licence
-------

[BSD 3-Clause Licence](LICENSE).

[Rhai]: https://rhai.rs
[Rust]: https://www.rust-lang.org/
[USP]: https://usp.technology/
[Axiros]: https://www.axiros.com/
File renamed without changes.
23 changes: 13 additions & 10 deletions rusp-lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,25 @@ Documentation and examples for its use can be found on [docs.rs](https://docs.rs

## What else?

You may use this crate however you like under the **BSD 3-Clause Licence**.
You may use this crate however you like under the [BSD 3-Clause Licence](LICENSE).

The toolkit is still far from feature complete but already a big aid in our product development and also helped to find one or the other discrepancy in the standard.

Feel free to spread the word or drop us a note if you like it. Collaboration on this crate is highly welcome as are pull requests in [our GitHub repo](https://github.com/axiros/rusp/).
Feel free to spread the word or drop us a note if you like it. Collaboration on
this crate is highly welcome as are pull requests in [our GitHub
repo](https://github.com/axiros/rusp/).

## Contact us

If you are in need of software for **USP** management software (agent, controller or testing) or expertise please get in touch with us via our [web form](https://www.axiros.com). We're also happy to solve all other device management and monitoring needs!

[Rust]: https://www.rust-lang.org/
[USP]: https://usp.technology/
[BBF]: https://www.broadband-forum.org/
[Axiros]: https://www.axiros.com/
If you are in need of software for [USP][] management software (agent,
controller or testing) or expertise please get [in touch with us][Axiros]. We're
also happy to solve all other device management and monitoring needs!

Licence
-------

[BSD 3-Clause Licence](LICENSE).

[Rhai]: https://rhai.rs
[Rust]: https://www.rust-lang.org/
[USP]: https://usp.technology/
[Axiros]: https://www.axiros.com/
[BBF]: https://www.broadband-forum.org/

0 comments on commit b0d44af

Please sign in to comment.