Crate nt_client

Source
Expand description

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};

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

  • 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.

Modules§

data
Data sent between a NetworkTables connection.
error
NetworkTables client error types.
publish
Topic publishers.
subscribe
Topic subscribers.
topic
Named data channels.

Macros§

path
Creates a TopicPath containing the segments.

Structs§

Client
The client used to interact with a NetworkTables server.
ClientHandle
A cheaply-clonable handle to the client used to create topics.
NetworkTablesTime
Time information about a NetworkTables server and client.
NewClientOptions
Options when creating a new Client.

Enums§

NTAddr
Represents an address that a NetworkTables client can connect to.

Functions§

reconnect
Continuously calls init with a constructed Client whenever it returns an error, effectively becoming a reconnect handler.