Skip to content

Commit cede8e5

Browse files
committed
prepare-to-publish
1 parent e192aed commit cede8e5

File tree

10 files changed

+300
-10
lines changed

10 files changed

+300
-10
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

osc-adapter-osc-types/Cargo.toml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
[package]
22
name = "osc-adapter-osc-types"
3-
version = "0.1.0"
3+
version = "0.1.0-alpha.1"
44
edition = "2021"
5-
description = "Adapter between osc-ir and rust-osc-types"
5+
rust-version = "1.75"
6+
description = "Adapter between osc-ir and rust-osc-types for bidirectional conversion"
67
license = "MIT OR Apache-2.0"
8+
repository = "https://github.com/Nagitch/osc-data-model"
9+
homepage = "https://github.com/Nagitch/osc-data-model"
10+
documentation = "https://docs.rs/osc-adapter-osc-types"
11+
keywords = ["osc", "adapter", "rust-osc-types", "conversion"]
12+
categories = ["encoding", "data-structures"]
13+
readme = "README.md"
714

815
[features]
916
osc10 = ["dep:osc-types10", "osc-ir/osc10"]
1017
osc11 = ["dep:osc-types11", "osc-ir/osc11"]
1118

1219
[dependencies]
13-
osc-ir = { path = "../osc-ir", features = ["alloc"] }
20+
osc-ir = { version = "0.1.0-alpha.1", features = ["alloc"] }
1421
# Use crates.io when available; during local dev, replace with a path override in the root Cargo.toml [patch] if needed.
1522
osc-types10 = { version = "0.1.0-alpha.2", optional = true, default-features = false }
1623
osc-types11 = { version = "0.1.0-alpha.2", optional = true, default-features = false }
1724

1825
[dev-dependencies]
19-
osc-codec-msgpack = { path = "../osc-codec-msgpack" }
26+
osc-codec-msgpack = { version = "0.1.0-alpha.1" }

osc-adapter-osc-types/README.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# osc-adapter-osc-types
2+
3+
⚠️ **EXPERIMENTAL** ⚠️
4+
This crate is experimental and APIs may change significantly between versions.
5+
6+
Bidirectional adapter between `osc-ir` intermediate representation and `rust-osc-types` for seamless conversion between OSC data formats.
7+
8+
## Features
9+
10+
- **Bidirectional Conversion**: Convert between `IrValue` and OSC types from `rust-osc-types`
11+
- **OSC Version Support**: Support for both OSC 1.0 and OSC 1.1 via feature flags
12+
- **Message Conversion**: Convert OSC messages to/from IR representation
13+
- **Type Preservation**: Maintain type information during conversion
14+
- **no_std Compatible**: Works in no_std environments with `alloc`
15+
16+
## Usage
17+
18+
Add this to your `Cargo.toml`:
19+
20+
```toml
21+
[dependencies]
22+
osc-adapter-osc-types = { version = "0.1.0-alpha.1", features = ["osc10"] }
23+
```
24+
25+
### OSC 1.0 Support
26+
27+
```toml
28+
[dependencies]
29+
osc-adapter-osc-types = { version = "0.1.0-alpha.1", features = ["osc10"] }
30+
```
31+
32+
### OSC 1.1 Support
33+
34+
```toml
35+
[dependencies]
36+
osc-adapter-osc-types = { version = "0.1.0-alpha.1", features = ["osc11"] }
37+
```
38+
39+
### Basic Example
40+
41+
```rust
42+
use osc_adapter_osc_types::{osc_to_ir, ir_to_osc};
43+
use osc_ir::IrValue;
44+
45+
// Convert OSC message to IR
46+
let osc_msg = /* your OSC message */;
47+
let ir_value = osc_to_ir(&osc_msg);
48+
49+
// Convert back to OSC
50+
let restored_osc = ir_to_osc(&ir_value);
51+
```
52+
53+
### Message Conversion
54+
55+
```rust
56+
use osc_adapter_osc_types::{message_to_ir, ir_to_message};
57+
use osc_ir::IrValue;
58+
59+
// Create an OSC message representation in IR
60+
let address = "/oscillator/frequency";
61+
let args = vec![
62+
IrValue::from(440.0), // frequency
63+
IrValue::from("sine") // waveform
64+
];
65+
66+
let ir_message = message_to_ir(address, args);
67+
68+
// Convert IR back to OSC message format
69+
if let Some((addr, arguments)) = ir_to_message(&ir_message) {
70+
println!("Address: {}", addr);
71+
println!("Arguments: {:?}", arguments);
72+
}
73+
```
74+
75+
### Type Conversions
76+
77+
The adapter handles conversion between OSC types and IR values:
78+
79+
- **Integers**: `i32``IrValue::Integer`
80+
- **Floats**: `f32``IrValue::Float`
81+
- **Strings**: `String``IrValue::String`
82+
- **Binary Data**: `Vec<u8>``IrValue::Binary`
83+
- **Arrays**: OSC arrays ↔ `IrValue::Array`
84+
- **Timestamps**: OSC timetags ↔ `IrValue::Timestamp`
85+
86+
## Feature Flags
87+
88+
- `osc10`: Enable OSC 1.0 support (basic types, bundles, timetags)
89+
- `osc11`: Enable OSC 1.1 support (includes OSC 1.0 plus additional types)
90+
91+
Choose the appropriate feature flag based on the OSC version you need to support.
92+
93+
## API Reference
94+
95+
### Core Functions
96+
97+
- `osc_to_ir(osc: &OscType) -> IrValue` - Convert OSC type to IR
98+
- `ir_to_osc(ir: &IrValue) -> OscType` - Convert IR to OSC type
99+
- `message_to_ir(address: &str, args: Vec<IrValue>) -> IrValue` - Create IR message
100+
- `ir_to_message(ir: &IrValue) -> Option<(&str, &[IrValue])>` - Extract message from IR
101+
102+
## Compatibility
103+
104+
This adapter is designed to work with:
105+
- `osc-ir` for intermediate representation
106+
- `rust-osc-types` for OSC protocol implementation
107+
- Both `osc-codec-json` and `osc-codec-msgpack` for serialization
108+
109+
## License
110+
111+
Licensed under either of
112+
113+
* Apache License, Version 2.0 ([LICENSE-APACHE](../LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
114+
* MIT license ([LICENSE-MIT](../LICENSE-MIT) or http://opensource.org/licenses/MIT)
115+
116+
at your option.

osc-adapter-osc-types/src/lib.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
//! # osc-adapter-osc-types
2+
//!
3+
//! ⚠️ **EXPERIMENTAL** ⚠️
4+
//! This crate is experimental and APIs may change significantly between versions.
5+
//!
6+
//! Bidirectional adapter between `osc-ir` intermediate representation and `rust-osc-types`
7+
//! for seamless conversion between OSC data formats.
8+
//!
9+
//! ## Features
10+
//!
11+
//! - **Bidirectional Conversion**: Convert between `IrValue` and OSC types from `rust-osc-types`
12+
//! - **OSC Version Support**: Support for both OSC 1.0 and OSC 1.1 via feature flags
13+
//! - **Message Conversion**: Convert OSC messages to/from IR representation
14+
//! - **Type Preservation**: Maintain type information during conversion
15+
//! - **no_std Compatible**: Works in no_std environments with `alloc`
16+
//!
17+
//! ## Usage
18+
//!
19+
//! ```rust
20+
//! # #[cfg(any(feature = "osc10", feature = "osc11"))]
21+
//! # {
22+
//! use osc_adapter_osc_types::{message_to_ir, ir_to_message};
23+
//! use osc_ir::IrValue;
24+
//!
25+
//! // Create an OSC message representation in IR
26+
//! let address = "/oscillator/frequency";
27+
//! let args = vec![
28+
//! IrValue::from(440.0), // frequency
29+
//! IrValue::from("sine") // waveform
30+
//! ];
31+
//!
32+
//! let ir_message = message_to_ir(address, args);
33+
//!
34+
//! // Convert IR back to OSC message format
35+
//! if let Some((addr, arguments)) = ir_to_message(&ir_message) {
36+
//! println!("Address: {}", addr);
37+
//! println!("Arguments: {:?}", arguments);
38+
//! }
39+
//! # }
40+
//! ```
41+
142
#![cfg_attr(not(test), no_std)]
243

344
extern crate alloc;

osc-codec-json/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ osc10 = ["osc-ir/osc10"]
1818
osc11 = ["osc10", "osc-ir/osc11"]
1919

2020
[dependencies]
21-
osc-ir = { version = "0.1.0-alpha.1", path = "../osc-ir", features = ["alloc"] }
21+
osc-ir = { version = "0.1.0-alpha.1", features = ["alloc"] }
2222
serde = { version = "1", features = ["derive"] }
2323
serde_json = "1"
2424
base64 = "0.22"

osc-codec-json/src/lib.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
//! # osc-codec-json
2+
//!
3+
//! ⚠️ **EXPERIMENTAL** ⚠️
4+
//! This crate is experimental and APIs may change significantly between versions.
5+
//!
6+
//! JSON codec for the `osc-ir` intermediate representation, enabling seamless conversion
7+
//! between OSC data structures and JSON format.
8+
//!
9+
//! ## Features
10+
//!
11+
//! - **Bidirectional Conversion**: Convert `IrValue` to/from JSON
12+
//! - **Bundle Support**: Full support for OSC bundles with nested structures
13+
//! - **Type Preservation**: Special handling for binary data, timestamps, and extended types
14+
//! - **OSC Compatibility**: Support for OSC 1.0 and 1.1 features via feature flags
15+
//!
16+
//! ## Usage
17+
//!
18+
//! ```rust
19+
//! use osc_ir::{IrValue, IrBundle, IrTimetag};
20+
//! use osc_codec_json::{to_json, from_json};
21+
//!
22+
//! // Create some data
23+
//! # #[cfg(feature = "osc10")]
24+
//! # {
25+
//! let mut bundle = IrBundle::new(IrTimetag::from_ntp(12345));
26+
//! bundle.add_message(IrValue::from("hello"));
27+
//! bundle.add_message(IrValue::from(42));
28+
//!
29+
//! let value = IrValue::Bundle(bundle);
30+
//!
31+
//! // Convert to JSON
32+
//! let json = to_json(&value);
33+
//! println!("{}", serde_json::to_string_pretty(&json).unwrap());
34+
//!
35+
//! // Convert back from JSON
36+
//! let restored = from_json(&json);
37+
//! assert_eq!(value, restored);
38+
//! # }
39+
//! ```
40+
141
use osc_ir::{IrValue, IrTimestamp, IrBundle, IrBundleElement, IrTimetag};
242
use serde_json::Value as J;
343
use base64::Engine;

osc-codec-msgpack/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ categories = ["encoding"]
1313
readme = "README.md"
1414

1515
[dependencies]
16-
osc-ir = { version = "0.1.0-alpha.1", path = "../osc-ir", features = ["alloc", "serde"] }
16+
osc-ir = { version = "0.1.0-alpha.1", features = ["alloc", "serde"] }
1717
serde = { version = "1", features = ["derive"] }
1818
rmp-serde = "1"
1919

osc-codec-msgpack/src/lib.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,45 @@
1+
//! # osc-codec-msgpack
2+
//!
3+
//! ⚠️ **EXPERIMENTAL** ⚠️
4+
//! This crate is experimental and APIs may change significantly between versions.
5+
//!
6+
//! MessagePack codec for the `osc-ir` intermediate representation, enabling efficient binary
7+
//! serialization of OSC data structures.
8+
//!
9+
//! ## Features
10+
//!
11+
//! - **Bidirectional Conversion**: Convert `IrValue` to/from MessagePack binary format
12+
//! - **Efficient Storage**: Compact binary representation with MessagePack
13+
//! - **Bundle Support**: Full support for OSC bundles with nested structures
14+
//! - **Type Preservation**: Native support for binary data, timestamps, and all OSC types
15+
//! - **Cross-Format Compatibility**: Works seamlessly with JSON codec for the same data
16+
//!
17+
//! ## Usage
18+
//!
19+
//! ```rust
20+
//! use osc_ir::{IrValue, IrBundle, IrTimetag};
21+
//! use osc_codec_msgpack::{to_msgpack, from_msgpack};
22+
//!
23+
//! // Create some data
24+
//! # #[cfg(feature = "osc10")]
25+
//! # {
26+
//! let mut bundle = IrBundle::new(IrTimetag::from_ntp(12345));
27+
//! bundle.add_message(IrValue::from("hello"));
28+
//! bundle.add_message(IrValue::from(42));
29+
//! bundle.add_message(IrValue::from(vec![1u8, 2, 3, 4])); // binary data
30+
//!
31+
//! let value = IrValue::Bundle(bundle);
32+
//!
33+
//! // Convert to MessagePack
34+
//! let msgpack_data = to_msgpack(&value);
35+
//! println!("Serialized {} bytes", msgpack_data.len());
36+
//!
37+
//! // Convert back from MessagePack
38+
//! let restored = from_msgpack(&msgpack_data);
39+
//! assert_eq!(value, restored);
40+
//! # }
41+
//! ```
42+
143
use osc_ir::IrValue;
244

345
pub type EncodeResult<T> = Result<T, rmp_serde::encode::Error>;

osc-devtools/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ categories = ["development-tools"]
1313
readme = "README.md"
1414

1515
[dependencies]
16-
osc-ir = { version = "0.1.0-alpha.1", path = "../osc-ir", features = ["alloc", "serde"] }
17-
osc-codec-json = { version = "0.1.0-alpha.1", path = "../osc-codec-json" }
18-
osc-codec-msgpack = { version = "0.1.0-alpha.1", path = "../osc-codec-msgpack" }
16+
osc-ir = { version = "0.1.0-alpha.1", features = ["alloc", "serde"] }
17+
osc-codec-json = { version = "0.1.0-alpha.1" }
18+
osc-codec-msgpack = { version = "0.1.0-alpha.1" }
1919
clap = { workspace = true }
2020
anyhow = "1"

osc-ir/src/lib.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
//! # osc-ir
2+
//!
3+
//! ⚠️ **EXPERIMENTAL** ⚠️
4+
//! This crate is experimental and APIs may change significantly between versions.
5+
//!
6+
//! A protocol-agnostic Intermediate Representation (IR) for OSC-adjacent data structures,
7+
//! designed to work seamlessly with JSON, MessagePack, and other serialization formats.
8+
//!
9+
//! ## Features
10+
//!
11+
//! - **OSC Version Support**: Configurable OSC 1.0 and OSC 1.1 support via feature flags
12+
//! - **no_std Compatible**: Core functionality works without std (requires `alloc` feature for owned containers)
13+
//! - **Bundle Support**: Full OSC Bundle implementation with nested bundle support
14+
//! - **Flexible Types**: Support for all OSC types including timestamps, binary data, and extensible types
15+
//! - **Serde Integration**: Optional serde support for JSON/MessagePack serialization
16+
//!
17+
//! ## Basic Usage
18+
//!
19+
//! ```rust
20+
//! use osc_ir::{IrValue, IrBundle, IrTimetag};
21+
//!
22+
//! // Create basic values
23+
//! let message = IrValue::from("hello world");
24+
//! let number = IrValue::from(42);
25+
//! let boolean = IrValue::from(true);
26+
//!
27+
//! // Create arrays
28+
//! let array = IrValue::from(vec![
29+
//! IrValue::from(1),
30+
//! IrValue::from(2),
31+
//! IrValue::from(3)
32+
//! ]);
33+
//!
34+
//! // Create bundles with timetags
35+
//! # #[cfg(feature = "osc10")]
36+
//! # {
37+
//! let mut bundle = IrBundle::new(IrTimetag::from_ntp(12345));
38+
//! bundle.add_message(message);
39+
//! bundle.add_message(number);
40+
//!
41+
//! let bundle_value = IrValue::Bundle(bundle);
42+
//! # }
43+
//! ```
44+
145
#![cfg_attr(not(test), no_std)]
246

347
extern crate alloc;

0 commit comments

Comments
 (0)