Actually comment ogg_pager

Signed-off-by: Serial <69764315+Serial-ATA@users.noreply.github.com>
This commit is contained in:
Serial 2021-06-29 15:02:39 -04:00
parent fb531877ac
commit 67d0e75655
4 changed files with 11 additions and 2 deletions

2
ogg_pager/Cargo.lock generated
View file

@ -10,7 +10,7 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "ogg_pager"
version = "0.1.4"
version = "0.1.5"
dependencies = [
"byteorder",
]

View file

@ -1,6 +1,6 @@
[package]
name = "ogg_pager"
version = "0.1.4"
version = "0.1.5"
authors = ["Serial <69764315+Serial-ATA@users.noreply.github.com>"]
edition = "2018"
repository = "https://github.com/Serial-ATA/lofty-rs"

View file

@ -5,9 +5,13 @@ pub type Result<T> = std::result::Result<T, PageError>;
#[derive(Debug)]
pub enum PageError {
/// The reader contains a page with a nonzero version
InvalidVersion,
/// The reader contains a page with a segment count < 1
BadSegmentCount,
/// The reader contains a page without a magic signature (OggS)
MissingMagic,
/// Any std::io::Error
Io(std::io::Error),
}

View file

@ -21,6 +21,7 @@ pub struct Page {
}
impl Page {
/// Convert the Page to Vec<u8> for writing
pub fn as_bytes(&self) -> Vec<u8> {
let mut bytes = Vec::new();
let segments = self.segments();
@ -40,10 +41,12 @@ impl Page {
bytes
}
/// Returns the Page's segment table as Vec<u8>
pub fn segments(&self) -> Vec<u8> {
segments(&*self.content)
}
/// Attempts to get a Page from a reader
pub fn read<V>(mut data: V) -> Result<Self>
where
V: Read + Seek,
@ -97,10 +100,12 @@ impl Page {
})
}
/// Generates the CRC checksum of the page
pub fn gen_crc(&mut self) {
self.checksum = crc::crc32(&*self.as_bytes());
}
/// Extends the Page's content, returning another Page if too much data was provided
pub fn extend(&mut self, content: &[u8]) -> Option<Page> {
let self_len = self.content.len();
let content_len = content.len();