pub struct AudioFile { /* private fields */ }Expand description
Represents an audio file stream that can be either encrypted or unencrypted.
AudioFile provides a unified interface for handling audio streams, wrapping
all downloads in a 32 KiB buffer. For encrypted content, additional 2 KiB
block processing is applied through the Decrypt implementation.
Implementations§
Source§impl AudioFile
impl AudioFile
Sourcepub fn try_from_download<P>(
track: &Track,
download: StreamDownload<P>,
) -> Result<Self>
pub fn try_from_download<P>( track: &Track, download: StreamDownload<P>, ) -> Result<Self>
Creates a new AudioFile from a track and its download stream.
This method wraps the download in a 32 KiB buffer and then:
- For encrypted tracks: adds
Decrypthandler for 2 KiB block processing - For unencrypted tracks: uses the buffered download directly
§Arguments
track- The track metadata containing encryption informationdownload- The underlying download stream
§Type Parameters
P- The storage provider type implementingStorageProvider
§Returns
A new AudioFile configured for the track
§Errors
Error::Unimplemented- Track uses unsupported encryptionError::PermissionDenied- Decryption key not availableError::InvalidData- Failed to create decryptor- Standard I/O errors from stream setup
Trait Implementations§
Source§impl MediaSource for AudioFile
Implements the MediaSource trait required by Symphonia for media playback.
impl MediaSource for AudioFile
Implements the MediaSource trait required by Symphonia for media playback.
This implementation provides metadata about the stream’s capabilities and properties:
- Seekability: determined by whether the track is a livestream
- Byte length: provided if known from the track metadata
Source§fn is_seekable(&self) -> bool
fn is_seekable(&self) -> bool
Returns whether seeking is supported in this audio stream.
§Returns
truefor normal audio filesfalsefor livestreams
Source§impl Read for AudioFile
Implements reading from the audio stream.
impl Read for AudioFile
Implements reading from the audio stream.
This implementation delegates all read operations directly to the underlying stream, whether it’s a decrypted stream or raw download stream, providing transparent handling of encrypted and unencrypted content.
§Arguments
buf- Buffer to read data into
§Returns
Number of bytes read, or 0 at end of stream
§Errors
Propagates errors from the underlying stream:
InvalidInput- Buffer position invalidInvalidData- Decryption failed- Standard I/O errors
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Source§impl Seek for AudioFile
Implements seeking within the audio stream.
impl Seek for AudioFile
Implements seeking within the audio stream.
This implementation delegates all seek operations directly to the underlying stream.
Note that seeking may not be available for livestreams, which can be checked via
the is_seekable() method.
§Arguments
pos- Seek position (Start/Current/End)
§Returns
New position in the stream
§Errors
Propagates errors from the underlying stream:
InvalidInput- Invalid seek positionUnexpectedEof- Seek beyond end of fileUnsupported- Seeking from end with unknown size
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)