pub struct Page {
pub abgp: u64,
pub serial: u32,
pub seq_num: u32,
pub start: u64,
pub end: u64,
/* private fields */
}
Expand description
An OGG page
Fields
abgp: u64
The page’s absolute granule position
serial: u32
The page’s stream serial number
seq_num: u32
The page’s sequence number
start: u64
The position in the stream the page started at
end: u64
The position in the stream the page ended
Implementations
sourceimpl Page
impl Page
sourcepub fn new(
header_type_flag: u8,
abgp: u64,
stream_serial: u32,
sequence_number: u32,
content: Vec<u8>
) -> Result<Self>
pub fn new(
header_type_flag: u8,
abgp: u64,
stream_serial: u32,
sequence_number: u32,
content: Vec<u8>
) -> Result<Self>
Create a new Page
This will have the following defaults:
checksum
= 0start
= 0end
=content.len()
Errors
content.len()
> MAX_CONTENT_SIZE
Example
use ogg_pager::CONTAINS_FIRST_PAGE_OF_BITSTREAM;
// Creating the identification header
let ident_header_packet = vec![...];
let stream_serial_number = 2784419176;
let page = Page::new(
CONTAINS_FIRST_PAGE_OF_BITSTREAM,
0,
stream_serial_number,
ident_header_packet,
);
sourcepub fn as_bytes(&self) -> Result<Vec<u8>>
pub fn as_bytes(&self) -> Result<Vec<u8>>
Convert the Page to Vec
NOTE: This will write the checksum as is. It is likely Page::gen_crc
will have
to be used prior.
Errors
See segment_table
sourcepub fn read<V>(data: &mut V, skip_content: bool) -> Result<Self> where
V: Read + Seek,
pub fn read<V>(data: &mut V, skip_content: bool) -> Result<Self> where
V: Read + Seek,
Attempts to get a Page from a reader
Use skip_content
to only read the header, and skip over the content.
Errors
sourcepub fn extend(&mut self, content: &[u8]) -> Result<Option<Page>>
pub fn extend(&mut self, content: &[u8]) -> Result<Option<Page>>
Extends the Page’s content, returning another Page if too much data was provided
This will do nothing if content
is greater than the max page size. In this case,
paginate
should be used.
Errors
Only applicable if a new page is created:
See Page::gen_crc
sourcepub fn content(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn content(&self) -> &[u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Returns the page’s content
sourcepub fn take_content(self) -> Vec<u8>
pub fn take_content(self) -> Vec<u8>
Consumes the page and returns it’s content
sourcepub fn header_type(&self) -> u8
pub fn header_type(&self) -> u8
Returns the page’s header type flag
sourcepub fn checksum(&self) -> u32
pub fn checksum(&self) -> u32
Returns the page’s checksum
NOTE: This will not generate a new CRC. It will return
the CRC as-is. Use Page::gen_crc
to generate a new one.
sourcepub fn segment_table(&self) -> Result<Vec<u8>>
pub fn segment_table(&self) -> Result<Vec<u8>>
Trait Implementations
impl StructuralPartialEq for Page
Auto Trait Implementations
impl RefUnwindSafe for Page
impl Send for Page
impl Sync for Page
impl Unpin for Page
impl UnwindSafe for Page
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more