File I/O Interface¶
-
palace.
current_fileio
() → Optional[Callable[[str], palace.FileIO]]¶ Return the file I/O factory currently in used by audio decoders.
If the default is being used, return
None
.
-
palace.
use_fileio
(factory: Optional[Callable[[str], FileIO]], buffer_size: int = 8192) → None¶ Set the file I/O factory instance to be used by audio decoders.
If
factory=None
is provided, revert to the default.
-
class
palace.
FileIO
(*args, **kwargs)¶ File I/O protocol.
This static duck type defines methods required to be used by palace decoders. Despite its name, a
FileIO
is not necessarily created from a file, but any seekable finite input stream.Many classes defined in the standard library module
io
are compatible with this protocol.Note
Since PEP 544 is only implemented in Python 3.8+, type checking for this on earlier Python version might not work as expected.
-
abstract
close
() → None¶ Close the file.
-
abstract
read
(size: int) → bytes¶ Read at most size bytes, returned as bytes.
-
abstract
seek
(offset: int, whence: int = 0) → int¶ Move to new file position and return the file position.
- Parameters
offset (int) – A byte count.
whence (int, optional) – Either 0 (default, move relative to start of file), 1 (move relative to current position) or 2 (move relative to end of file).
-
abstract