pub struct NtTopic<'nt, T: DataWrap> {
pub(crate) conn: &'nt NtConn,
pub(crate) name: String,
pub(crate) pubuid: i32,
pub(crate) _marker: PhantomData<T>,
}
Expand description
A NetworkTables topic
This structure represents a published topic on the NetworkTables server. It allows you to set the value of the topic. The topic is automatically unpublished when this structure is dropped.
Fields§
§conn: &'nt NtConn
§name: String
§pubuid: i32
§_marker: PhantomData<T>
Implementations§
Source§impl<T: DataWrap + Debug> NtTopic<'_, T>
impl<T: DataWrap + Debug> NtTopic<'_, T>
Sourcepub async fn set(&mut self, val: T) -> Result<()>
pub async fn set(&mut self, val: T) -> Result<()>
Set the value of the topic.
§Arguments
val
- The new value to set the topic to.
§Examples
use minint::{NtConn, datatype::DataType};
#[tokio::main]
async fn main() {
// Connect to the NetworkTables server
let conn = NtConn::new("10.0.0.2", "my_client").await.unwrap();
// Publish a new topic
let mut topic = conn.publish::<f64>("my_topic").await.unwrap();
// Set the value of the topic
topic.set(3.14159).await.unwrap();
// ...
}
Trait Implementations§
Auto Trait Implementations§
impl<'nt, T> Freeze for NtTopic<'nt, T>
impl<'nt, T> !RefUnwindSafe for NtTopic<'nt, T>
impl<'nt, T> Send for NtTopic<'nt, T>where
T: Send,
impl<'nt, T> Sync for NtTopic<'nt, T>where
T: Sync,
impl<'nt, T> Unpin for NtTopic<'nt, T>where
T: Unpin,
impl<'nt, T> !UnwindSafe for NtTopic<'nt, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more