diff --git a/ogg_pager/Cargo.lock b/ogg_pager/Cargo.lock index 2e1df243..2764e487 100644 --- a/ogg_pager/Cargo.lock +++ b/ogg_pager/Cargo.lock @@ -10,7 +10,7 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "ogg_pager" -version = "0.1.4" +version = "0.1.5" dependencies = [ "byteorder", ] diff --git a/ogg_pager/Cargo.toml b/ogg_pager/Cargo.toml index 7a05f192..abdf43c1 100644 --- a/ogg_pager/Cargo.toml +++ b/ogg_pager/Cargo.toml @@ -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" diff --git a/ogg_pager/src/error.rs b/ogg_pager/src/error.rs index 22fad0ae..4fcd23a4 100644 --- a/ogg_pager/src/error.rs +++ b/ogg_pager/src/error.rs @@ -5,9 +5,13 @@ pub type Result = std::result::Result; #[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), } diff --git a/ogg_pager/src/lib.rs b/ogg_pager/src/lib.rs index 0422b342..3b6695bf 100644 --- a/ogg_pager/src/lib.rs +++ b/ogg_pager/src/lib.rs @@ -21,6 +21,7 @@ pub struct Page { } impl Page { + /// Convert the Page to Vec for writing pub fn as_bytes(&self) -> Vec { let mut bytes = Vec::new(); let segments = self.segments(); @@ -40,10 +41,12 @@ impl Page { bytes } + /// Returns the Page's segment table as Vec pub fn segments(&self) -> Vec { segments(&*self.content) } + /// Attempts to get a Page from a reader pub fn read(mut data: V) -> Result 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 { let self_len = self.content.len(); let content_len = content.len();