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
impl Dac
Sourcepub fn new(info: DacInfo, backend: Box<dyn StreamBackend>) -> Self
pub fn new(info: DacInfo, backend: Box<dyn StreamBackend>) -> Self
Create a new device from a backend.
Sourcepub fn caps(&self) -> &DacCapabilities
pub fn caps(&self) -> &DacCapabilities
Returns the device capabilities.
Sourcepub fn has_backend(&self) -> bool
pub fn has_backend(&self) -> bool
Returns whether the device has a backend (not yet used for a stream).
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Returns whether the device is connected.
Sourcepub fn start_stream(self, cfg: StreamConfig) -> Result<(Stream, DacInfo)>
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
Streamto 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.