7 releases (breaking)

0.6.1 Apr 28, 2021
0.6.0 Apr 21, 2021
0.5.0 Apr 1, 2021
0.4.0 Mar 18, 2021
0.1.0 Jun 25, 2020

#19 in Video

Download history 5/week @ 2021-01-14 2/week @ 2021-01-21 1/week @ 2021-02-04 32/week @ 2021-02-11 4/week @ 2021-02-18 2/week @ 2021-02-25 21/week @ 2021-03-04 17/week @ 2021-03-11 17/week @ 2021-03-18 18/week @ 2021-03-25 24/week @ 2021-04-01 12/week @ 2021-04-08 27/week @ 2021-04-15 20/week @ 2021-04-22 28/week @ 2021-04-29

64 downloads per month

BSD-2-Clause

4MB
90K SLoC

C 90K SLoC // 0.2% comments Rust 427 SLoC // 0.0% comments Shell 17 SLoC // 0.3% comments

librist-rust

crates.io version Documentation

Rust wapper for librist, allowing you to use the RIST protocol within Rust applications.

Feature support

This wrapper is in very early stages and currently does not support a number of librist features:

  • Sending - not supported
  • Receiving - basic support
  • Custom authentication hooks - not supported
  • Out-of-band data - not supported
  • librist logging configuration supported
  • stats reporting - not supported
  • data callback - not supported
  • NAK control - not supported

Example

Receive and hex-dump RIST packets,

use librist_rust::{LoggingSettings, LogLevel, ReceiverContext, Profile, PeerConfig, RistError, DataReadResponse};
use std::io::stderr;

fn main() {
   let url = std::env::args().skip(1).next()
       .expect("Please supply one URL argument");
   let peer_config = PeerConfig::parse_address(&url)
       .expect(&format!("Unable to parse {:?}",url));
   let logging_settings = LoggingSettings::file(LogLevel::Info, stderr())
       .expect("LoggingSettings::file() failed");
   let mut ctx = ReceiverContext::create(Profile::Main, logging_settings)
       .expect("Context::receiver_create failed");

   ctx.peer_create(peer_config)
       .expect("peer_create() failed");

   // Have to call these or the connection with the librist 'ristsender' tool will not be
   // established
   ctx.auth_handler_set().expect("auth_handler_set() failed");
   ctx.oob_callback_set().expect("oob_callback_set() failed");

   ctx.start();
   loop {
       match ctx.data_read(std::time::Duration::from_secs(1)) {
           Ok(DataReadResponse::NoData) => {
               println!("No data received within timeout window")
           },
           Ok(DataReadResponse::Data { block, queue_size }) => {
               println!("Got a data block; queue now at {} items", queue_size);
               hexdump::hexdump(block.payload())
           },
           Err(e) => {
               println!("data_read() failed {:?}", e);
               return;
           },
       }
   }
}

The above example is in this project, so from a checked-out copy you can run the following to dump payloads of RIST packets sent to port 12344 on localhost,

cargo run --release --example receiver rist://@127.0.0.1:12344

Dependencies