#sdk #platform #settings #deserialize #datagram #serde-default #error #sinusoidal

sinusoidal

The official SDK to write rust apps for the Sinusoidal Systems Digital Measurement Platform

3 releases

Uses new Rust 2024

new 0.1.2 May 22, 2025
0.1.1 May 22, 2025
0.1.0 May 22, 2025

#1824 in Parser implementations

Custom license

17KB
441 lines

The Sinusoidal Framework Rust SDK

Apps are defined by implementing the [App] trait and run through a [Sinusoidal] object.

Example

use serde::Deserialize;
use sinusoidal::proto::streaming_api::Datagram;
use sinusoidal::*;
use std::io::Error;

struct MyApp {
  settings: MySettings,
}

#[derive(Debug, Clone, Deserialize)]
struct MySettings {
  #[serde(default)]
  input_streams: Vec<StreamId>,
}

impl App for MyApp {
  type Settings = MySettings;
  fn new(settings: MySettings) -> Self {
    MyApp{settings}
  }

  fn handle_connect(&mut self, connection: &mut Connection) -> Result<(), Error> {
    for stream_id in self.settings.input_streams.iter() {
      connection.subscribe(stream_id)?;
    }
    Ok(())
  }

  fn handle_packet(&mut self, _connections: &mut Connection, id: StreamId, d: Datagram) -> Result<(), Error> {
    println!("StreamId: {id}; Data: {d:?}");
    Ok(())
  }
}

pub fn main() -> Result<(), std::io::Error> {
  Sinusoidal::<MyApp>::new()?.run()
}

Dependencies

~0.9–3.5MB
~62K SLoC