Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/frando/async-osc
Async Rust library for the Open Sound Control (OSC) protocol
https://github.com/frando/async-osc
async-std open-sound-control osc rust
Last synced: about 1 month ago
JSON representation
Async Rust library for the Open Sound Control (OSC) protocol
- Host: GitHub
- URL: https://github.com/frando/async-osc
- Owner: Frando
- License: apache-2.0
- Created: 2021-02-20T15:13:09.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-20T15:29:20.000Z (almost 4 years ago)
- Last Synced: 2024-11-01T04:42:13.587Z (about 2 months ago)
- Topics: async-std, open-sound-control, osc, rust
- Language: Rust
- Homepage:
- Size: 18.6 KB
- Stars: 19
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE-APACHE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
async-osc
Async Rust library for the Open Sound Control (OSC) protocol
This crate implements an async interface on the [OSC 1.0](https://web.archive.org/web/20201211193930/http://opensoundcontrol.org/spec-1_0) protocol. It uses [`async-std`](https://docs.rs/async-std) for async networking and [`rosc`](https://docs.rs/rosc) for OSC encoding and decoding.
## Installation
```sh
$ cargo add async-osc
```## Example
```rust
use async_osc::{prelude::*, Error, OscPacket, OscSocket, OscType, Result};
use async_std::stream::StreamExt;#[async_std::main]
async fn main() -> Result<()> {
let mut socket = OscSocket::bind("localhost:5050").await?;// Open a second socket to send a test message.
async_std::task::spawn(async move {
let socket = OscSocket::bind("localhost:0").await?;
socket.connect("localhost:5050").await?;
socket
.send(("/volume", (0.9f32, "foo".to_string())))
.await?;
Ok::<(), Error>(())
});// Listen for incoming packets on the first socket.
while let Some(packet) = socket.next().await {
let (packet, peer_addr) = packet?;
eprintln!("Receive from {}: {:?}", peer_addr, packet);
match packet {
OscPacket::Bundle(_) => {}
OscPacket::Message(message) => match &message.as_tuple() {
("/volume", &[OscType::Float(vol), OscType::String(ref s)]) => {
eprintln!("Set volume: {} {}", vol, s);
}
_ => {}
},
}
}
Ok(())
}
```## Safety
This crate uses ``#![deny(unsafe_code)]`` to ensure everything is implemented in
100% Safe Rust.## Contributing
Want to join us? Check out our ["Contributing" guide][contributing] and take a
look at some of these issues:- [Issues labeled "good first issue"][good-first-issue]
- [Issues labeled "help wanted"][help-wanted][contributing]: https://github.com/Frando/async-osc/blob/master.github/CONTRIBUTING.md
[good-first-issue]: https://github.com/Frando/async-osc/labels/good%20first%20issue
[help-wanted]: https://github.com/Frando/async-osc/labels/help%20wanted## License
Licensed under either of Apache License, Version
2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in this crate by you, as defined in the Apache-2.0 license, shall
be dual licensed as above, without any additional terms or conditions.