pub struct NetworkTables<T: NTBackend> { /* private fields */ }
Expand description
Core struct representing a connection to a NetworkTables server
Implementations§
Source§impl NetworkTables<Client>
impl NetworkTables<Client>
Sourcepub async fn connect(
ip: &str,
client_name: &str,
) -> Result<NetworkTables<Client>>
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
Sourcepub async fn reconnect(&mut self)
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
.
pub fn add_connection_callback( &self, callback_type: ConnectionCallbackType, action: impl FnMut(&SocketAddr) + Send + 'static, )
pub fn call_rpc( &self, id: u16, parameter: Vec<u8>, callback: impl Fn(Vec<u8>) + Send + 'static, )
Source§impl NetworkTables<Server>
impl NetworkTables<Server>
Sourcepub fn bind(ip: &str, server_name: &str) -> NetworkTables<Server>
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.
Sourcepub fn add_connection_callback(
&mut self,
callback_type: ConnectionCallbackType,
action: impl FnMut(&SocketAddr) + Send + 'static,
)
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
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>
impl<T: NTBackend> NetworkTables<T>
Sourcepub fn entries(&self) -> HashMap<u16, EntryData>
pub fn entries(&self) -> HashMap<u16, EntryData>
Returns a copy of the entries recognizes by the connection
Sourcepub fn get_entry(&self, id: u16) -> Entry<'_, T>
pub fn get_entry(&self, id: u16) -> Entry<'_, T>
Gets the entry with the given id, returning an Entry
for the specified data
Sourcepub async fn create_entry(&self, data: EntryData) -> Result<u16>
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
Sourcepub fn delete_entry(&self, id: u16)
pub fn delete_entry(&self, id: u16)
Deletes the entry with the given id
Sourcepub fn clear_entries(&self)
pub fn clear_entries(&self)
Clears all the entries associated with this connection
Sourcepub fn update_entry(&self, id: u16, new_value: EntryValue)
pub fn update_entry(&self, id: u16, new_value: EntryValue)
Updates the entry of the given id, with the new value
Sourcepub fn add_callback<F>(&mut self, action: CallbackType, cb: F)
pub fn add_callback<F>(&mut self, action: CallbackType, cb: F)
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.
Sourcepub fn update_entry_flags(&self, id: u16, new_flags: u8)
pub fn update_entry_flags(&self, id: u16, new_flags: u8)
Updates the flags associated with the entry of the given id