Skip to main content

DataTrack

Struct DataTrack 

Source
pub struct DataTrack<L> { /* private fields */ }
Expand description

Track for communicating application-specific data between participants in room.

Implementations§

Source§

impl<L> DataTrack<L>

Source

pub fn info(&self) -> &DataTrackInfo

Information about the data track.

Source

pub fn is_published(&self) -> bool

Whether or not the track is still published.

Source

pub async fn wait_for_unpublish(&self)

Waits asynchronously until the track is unpublished.

Use this to trigger follow-up work once the track is no longer published. If the track is already unpublished, this method returns immediately.

Source§

impl DataTrack<Local>

Source

pub fn try_push(&self, frame: DataTrackFrame) -> Result<(), PushFrameError>

Try pushing a frame to subscribers of the track.

§Example
fn read_sensor() -> Vec<u8> {
    // Read some sensor data...
    vec![0xFA; 16]
}

let frame = read_sensor().into(); // Convert to frame
track.try_push(frame)?;

See DataTrackFrame for more ways to construct a frame and how to attach metadata.

§Errors

Pushing a frame can fail for several reasons:

  • The track has been unpublished by the local participant or SFU
  • The room is no longer connected
  • Frames are being pushed too fast
Source

pub fn unpublish(&self)

Unpublishes the track.

Source§

impl DataTrack<Remote>

Source

pub async fn subscribe( &self, ) -> Result<DataTrackStream, DataTrackSubscribeError>

Subscribes to the data track.

§Returns

A stream that yields DataTrackFrames as they arrive.

§Options

To set custom subscription options, see Self::subscribe_with_options.

§Multiple Subscriptions

An application may call subscribe more than once to process frames in multiple places. For example, one async task might plot values on a graph while another writes them to a file.

Internally, only the first call to subscribe communicates with the SFU and allocates the resources required to receive frames. Additional subscriptions reuse the same underlying pipeline and do not trigger additional signaling.

Note that newly created subscriptions only receive frames published after the initial subscription is established.

Source

pub async fn subscribe_with_options( &self, options: DataTrackSubscribeOptions, ) -> Result<DataTrackStream, DataTrackSubscribeError>

Subscribes to the data track, specifying custom options.

Same usage and return as Self::subscribe with an additional argument to specify options.

Source

pub fn publisher_identity(&self) -> &str

Identity of the participant who published the track.

Trait Implementations§

Source§

impl<L: Clone> Clone for DataTrack<L>

Source§

fn clone(&self) -> DataTrack<L>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<L: Debug> Debug for DataTrack<L>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<L> Freeze for DataTrack<L>

§

impl<L> RefUnwindSafe for DataTrack<L>
where L: RefUnwindSafe,

§

impl<L> Send for DataTrack<L>
where L: Send,

§

impl<L> Sync for DataTrack<L>
where L: Sync,

§

impl<L> Unpin for DataTrack<L>
where L: Unpin,

§

impl<L> UnsafeUnpin for DataTrack<L>

§

impl<L> UnwindSafe for DataTrack<L>
where L: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V