Struct NetworkTables

Source
pub struct NetworkTables<T: NTBackend> { /* private fields */ }
Expand description

Core struct representing a connection to a NetworkTables server

Implementations§

Source§

impl NetworkTables<Client>

Source

pub async fn connect( ip: &str, client_name: &str, ) -> Result<NetworkTables<Client>>

Connects over TCP to the given ip, with the given client_name

This call will block the thread until the client has completed the handshake with the server, at which point the connection will be valid to send and receive data over

Source

pub async fn reconnect(&mut self)

Attempts to reconnect to the NetworkTables server if the connection had been terminated.

This function should only be called if you are certain that the previous connection is dead. Connection status can be determined using callbacks specified with add_connection_callback.

Source

pub fn add_connection_callback( &self, callback_type: ConnectionCallbackType, action: impl FnMut(&SocketAddr) + Send + 'static, )

Source

pub fn call_rpc( &self, id: u16, parameter: Vec<u8>, callback: impl Fn(Vec<u8>) + Send + 'static, )

Source§

impl NetworkTables<Server>

Source

pub fn bind(ip: &str, server_name: &str) -> NetworkTables<Server>

Initializes an NT server over TCP and binds it to the given ip, with the given server name.

Source

pub fn add_connection_callback( &mut self, callback_type: ConnectionCallbackType, action: impl FnMut(&SocketAddr) + Send + 'static, )

Adds a callback for connection state updates regarding clients.

Depending on the chosen callback type, the callback will be called when a new client connects, or when an existing client disconnects from the server

Source

pub fn create_rpc( &mut self, data: EntryData, callback: impl Fn(Vec<u8>) -> Vec<u8> + Send + Sync + RefUnwindSafe + 'static, )

Source§

impl<T: NTBackend> NetworkTables<T>

Source

pub fn entries(&self) -> HashMap<u16, EntryData>

Returns a copy of the entries recognizes by the connection

Source

pub fn get_entry(&self, id: u16) -> Entry<'_, T>

Gets the entry with the given id, returning an Entry for the specified data

Source

pub async fn create_entry(&self, data: EntryData) -> Result<u16>

Creates a new entry with the specified data, returning the id assigned to it by the server This call may block if this connection is acting as a client, while it waits for the id to be assigned by the remote server

Source

pub fn delete_entry(&self, id: u16)

Deletes the entry with the given id

Source

pub fn clear_entries(&self)

Clears all the entries associated with this connection

Source

pub fn update_entry(&self, id: u16, new_value: EntryValue)

Updates the entry of the given id, with the new value

Source

pub fn add_callback<F>(&mut self, action: CallbackType, cb: F)
where F: FnMut(&EntryData) + Send + 'static,

Adds an entry callback of the given type.

Depending on what is chosen, the callback will be notified when a new entry is created, an existing entry is updated, or an existing entry is deleted.

Source

pub fn update_entry_flags(&self, id: u16, new_flags: u8)

Updates the flags associated with the entry of the given id

Trait Implementations§

Source§

impl<T: NTBackend> Drop for NetworkTables<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for NetworkTables<T>

§

impl<T> !RefUnwindSafe for NetworkTables<T>

§

impl<T> Send for NetworkTables<T>
where <T as NTBackend>::State: Send,

§

impl<T> Sync for NetworkTables<T>
where <T as NTBackend>::State: Send,

§

impl<T> Unpin for NetworkTables<T>

§

impl<T> !UnwindSafe for NetworkTables<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.