Skip to main content

Dac

Struct Dac 

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

A connected device that can start streaming sessions.

When starting a stream, the device is consumed and the backend ownership transfers to the stream. The DacInfo is returned alongside the stream so metadata remains accessible.

§Example

let device = open_device("my-device")?;
let config = StreamConfig::new(30_000);
let (stream, info) = device.start_stream(config)?;
println!("Streaming to: {}", info.name);

Implementations§

Source§

impl Dac

Source

pub fn new(info: DacInfo, backend: Box<dyn StreamBackend>) -> Self

Create a new device from a backend.

Source

pub fn info(&self) -> &DacInfo

Returns the device info.

Source

pub fn id(&self) -> &str

Returns the device ID.

Source

pub fn name(&self) -> &str

Returns the device name.

Source

pub fn kind(&self) -> &DacType

Returns the DAC type.

Source

pub fn caps(&self) -> &DacCapabilities

Returns the device capabilities.

Source

pub fn has_backend(&self) -> bool

Returns whether the device has a backend (not yet used for a stream).

Source

pub fn is_connected(&self) -> bool

Returns whether the device is connected.

Source

pub fn start_stream(self, cfg: StreamConfig) -> Result<(Stream, DacInfo)>

Starts a streaming session, consuming the device.

§Ownership

This method consumes the Dac because:

  • Each device can only have one active stream at a time.
  • The backend is moved into the Stream to ensure exclusive access.
  • This prevents accidental reuse of a device that’s already streaming.

The method returns both the Stream and a copy of DacInfo, so you retain access to device metadata (id, name, capabilities) after starting.

§Connection

If the device is not already connected, this method will establish the connection before creating the stream. Connection failures are returned as errors.

§Errors

Returns an error if:

  • The device backend has already been used for a stream.
  • The configuration is invalid (PPS out of range, invalid chunk size, etc.).
  • The backend fails to connect.

Auto Trait Implementations§

§

impl Freeze for Dac

§

impl !RefUnwindSafe for Dac

§

impl Send for Dac

§

impl !Sync for Dac

§

impl Unpin for Dac

§

impl !UnwindSafe for Dac

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.