Tiny Ogg stream manipulator
Ogg is a stream encapsulation format. It's not exclusively used for Vorbis or Opus audio files, but can encapsulate any type of continuous data streams for transmission protocols.
Personally, I consider Ogg to be an excellent binary data transmission protocol for UART/USART applications.
Overview
OggPacket
- The
OggPacketrepresents a single data packet, the fundamental unit of an Ogg stream. - Contains built-in capabilities for byte parsing and validation of complete packet structures.
- Provides checksum verification and regeneration functionality for raw packet bytes.
- Serves as a data container with capacity constraints (note: individual packets have size limitations).
- Supports data serialization to raw bytes and payload extraction.
The OggPacket have these functions:
;
;
;
;
;
;
;
;
;
;
;
;
;
OggStreamReader
OggStreamReader<R: Read + Debug>provides sequential access to Ogg streams.- Initialize with any
Readimplementer (e.g.,File,BufReader,Cursor) - Continuously call
get_packet()to retrieve packets from all streams in the source. - Return values:
Ok(Some(packet)): Valid packet retrievedOk(None): End of input reachedErr(io::Error): Error occurred
The OggStreamReader have these functions:
;
;
;
;
OggStreamWriter
OggStreamWriter<W: Write + Debug>handles Ogg stream output- Initialize with any
Writeimplementer (e.g.,File,BufWriter,Cursor) - Implements
Writetrait with automatic packet management:- Buffers data into packets
- Auto-seals and flushes full packets
- Customizable granule position calculation via
on_sealcallback
- Manual packet sealing via
seal_packet()
The OggStreamWriter have these functions:
;
;
;
;
;
;
;
;
For more information about each function please read the documentations.
/// * An ogg packet as a stream container
/// * An ogg packet reader
/// * An ogg packet as a stream container