PoseStream

Struct PoseStream 

Source
pub struct PoseStream { /* private fields */ }
Expand description

A live pose stream from one Enpose tracker device.

Dropping a PoseStream automatically disconnects it (see PoseStream::disconnect).

Implementations§

Source§

impl PoseStream

Source

pub fn from_ip(ip: IpAddr, create_thread: bool) -> Result<Self>

Connect a pose stream to the device at ip.

ip must be IPv4 — the Enpose API is IPv4-only. An IPv6 address is rejected with io::ErrorKind::Unsupported.

When create_thread is true, spawns the background receiver thread described in the module docs.

§Errors

Returns an io::Error if ip is not IPv4, or if the connection to the device cannot be established.

Source

pub fn from_device(device: &DeviceInfo, create_thread: bool) -> Result<Self>

Connect a pose stream to a device discovered via crate::DeviceDiscovery.

Convenience wrapper around Self::from_ip using DeviceInfo::ip.

Source

pub fn receive_pose_updates(&mut self, block: bool) -> Result<Vec<MarkerPose>>

Return the marker poses received from the stream.

When block is false, returns all poses that have arrived since the previous call, or an empty vector if none have — it never waits. When block is true, it waits for a pose update and returns the poses gathered so far; the wait is bounded by a 3-second timeout, so a blocking call still returns an empty vector if no update arrives within that window.

Call it repeatedly to keep receiving updates. In threaded mode the poses are those gathered by the background thread.

§Errors

Returns an io::Error only for an unrecoverable communication failure. In threaded mode this never returns an error.

Source

pub fn disconnect(&mut self)

Disconnect the stream, closing the connection to the device.

Idempotent, and called automatically when the PoseStream is dropped, so you only need to call it explicitly to disconnect early.

Trait Implementations§

Source§

impl Drop for PoseStream

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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.