nt_client 0.1.0

A blazingly fast NetworkTables 4.1 client
Documentation

nt_client

A blazingly fast WPI NetworkTables 4.1 client, written in Rust.

This is meant to be used within coprocessors that can send and receive data from the robot.

This is still a pre-1.0.0 release! Expect things to not work correctly and breaking changes until a full 1.0.0 release is available!

1.0.0 Release Checklist

  • Connecting to server
  • Subscribing to a topic
  • Publishing to a topic
  • 100% documentation coverage
  • Proper logging (instead of println!)
  • Examples
  • Better error handling (less .expect)
  • Reconnections
  • Caching

Installation

Add the following dependency to your Cargo.toml

nt_client = "0.1.0"

Or run the following command in your project root

cargo add nt_client

Example

A basic subscriber that prints changes to stdout

use nt_client::{Client, NewClientOptions, NTAddr};

#[tokio::main]
async fn main() {
    let options = NewClientOptions { addr: NTAddr::Local, ..Default::default() };
    let client = Client::new(options);

    let thing_topic = client.topic("/thing");
    tokio::spawn(async move {
        let mut sub = thing_topic.subscribe::<String>(Default::default())
            .await
            .expect("websocket connection closed!");

        while let Ok(recv) = sub.recv().await {
            println!("topic updated: '{recv}'")
        }
    });

    client.connect().await.unwrap();
});