Struct minint::NtTopic

source ·
pub struct NtTopic<'nt, T: DataType> {
    pub(crate) conn: &'nt NtConn,
    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§pubuid: i32§_marker: PhantomData<T>

Implementations§

source§

impl<T: DataType + Debug> NtTopic<'_, T>

source

pub async fn set(&mut self, val: T) -> Result<(), Box<dyn Error>>

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§

source§

impl<T: DataType> Drop for NtTopic<'_, T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V