nt_client 0.5.0

A blazingly fast NetworkTables 4.1 client
Documentation

A blazingly fast NetworkTables 4.1 client.

Provides a client that can be used to interface with a NetworkTables server. This is intended to be used within a coprocessor on the robot. Keep in mind that this is a pre-1.0.0 release, so many things may not work properly and expect breaking changes until a full 1.0.0 release is available.

Examples

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

# tokio_test::block_on(async {
let options = NewClientOptions { addr: NTAddr::Local, ..Default::default() };
let client = Client::new(options);

client.connect_setup(setup).await.unwrap();
# });

fn setup(client: &Client) {
    let thing_topic = client.topic("/thing");
    tokio::spawn(async move {
        let mut sub = thing_topic.subscribe(Default::default()).await.unwrap();

        loop {
            match sub.recv().await {
                Ok(ReceivedMessage::Updated((_topic, value))) => {
                    println!("topic updated: '{value}'");
                },
                Ok(_) => {},
                Err(err) => {
                    eprintln!("{err}");
                    break;
                },
            }
        }
    });
}

Feature flags

  • math: adds various common data types in wpimath.
  • struct: adds support for struct packing and unpacking, as well as implementing most data types enabled by the math feature.
  • protobuf: adds support for Google protobuf packing and unpacking, as well as implementing most data types enabled by the math feature.
  • publish_bypass: adds bypass versions of [Topic::publish] and [Topic::generic_publish] that do not wait for a server response. This is to serve as a workaround to issue #7680. Once that bug is fixed, this feature will likely be deprecated and/or removed.