osc-adapter-osc-types
⚠️ EXPERIMENTAL ⚠️
This crate is experimental and APIs may change significantly between versions.
Bidirectional adapter between osc-ir intermediate representation and rust-osc-types for seamless conversion between OSC data formats.
Features
- Bidirectional Conversion: Convert between
IrValueand OSC types fromrust-osc-types - OSC Version Support: Support for both OSC 1.0 and OSC 1.1 via feature flags
- Message Conversion: Convert OSC messages to/from IR representation
- Type Preservation: Maintain type information during conversion
- no_std Compatible: Works in no_std environments with
alloc
Usage
Add this to your Cargo.toml:
[]
= { = "0.1.0-alpha.1", = ["osc10"] }
OSC 1.0 Support
[]
= { = "0.1.0-alpha.1", = ["osc10"] }
OSC 1.1 Support
[]
= { = "0.1.0-alpha.1", = ["osc11"] }
Basic Example
use ;
use IrValue;
// Convert OSC message to IR
let osc_msg = /* your OSC message */;
let ir_value = osc_to_ir;
// Convert back to OSC
let restored_osc = ir_to_osc;
Message Conversion
use ;
use IrValue;
// Create an OSC message representation in IR
let address = "/oscillator/frequency";
let args = vec!;
let ir_message = message_to_ir;
// Convert IR back to OSC message format
if let Some = ir_to_message
Type Conversions
The adapter handles conversion between OSC types and IR values:
- Integers:
i32↔IrValue::Integer - Floats:
f32↔IrValue::Float - Strings:
String↔IrValue::String - Binary Data:
Vec<u8>↔IrValue::Binary - Arrays: OSC arrays ↔
IrValue::Array - Timestamps: OSC timetags ↔
IrValue::Timestamp
Feature Flags
osc10: Enable OSC 1.0 support (basic types, bundles, timetags)osc11: Enable OSC 1.1 support (includes OSC 1.0 plus additional types)
Choose the appropriate feature flag based on the OSC version you need to support.
API Reference
Core Functions
osc_to_ir(osc: &OscType) -> IrValue- Convert OSC type to IRir_to_osc(ir: &IrValue) -> OscType- Convert IR to OSC typemessage_to_ir(address: &str, args: Vec<IrValue>) -> IrValue- Create IR messageir_to_message(ir: &IrValue) -> Option<(&str, &[IrValue])>- Extract message from IR
Compatibility
This adapter is designed to work with:
osc-irfor intermediate representationrust-osc-typesfor OSC protocol implementation- Both
osc-codec-jsonandosc-codec-msgpackfor serialization
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.